api-platform
api-platform copied to clipboard
Mutation returns wrong payload
API Platform version(s) affected: 2.6.8
Description
We have a Message in a ManyToOne with Conversation (one conversation -> many messages). I create a message with a mutation, but the result of the mutation is wrong. Instead of returning the actual Messages in the toMany relationship, it returns all messages from the database.
If I manually refresh the query, the result is correct. The wrong result is shown only in the response of the mutation.
type Message implements Node {
id: ID!
content: String!
unread: Boolean
user: User
conversation: Conversation
createdAt: String!
}
type Conversation implements Node {
id: ID!
_id: Int!
participants: [Participant]
lastMessage: Message
messages: [Message]
}
type updateMessagePayload {
message: Message
clientMutationId: String
}
const mutation = graphql`
mutation ConversationMutation(
$input: createMessageInput!
) {
createMessage(input: $input) {
message {
conversation {
id
messages {
createdAt
content
user {
_id
}
}
}
}
}
}
`;
commit({
variables: {
input: {
content: message,
conversation: conversation.id,
user: user.id,
},
},
onCompleted: () => {
// refresh();
setMessage('');
messagesEndRef.current.scrollIntoView({ behavior: 'smooth' });
}
});