I have an Item
custom class, and I use a custom graphql mutation to update an item via a resolver in Cloud code so that I can do some other middleware things at the same time.
# custom schema.graphql
extend type Mutation {
editItem(input: UpdateItemInput!): UpdateItemPayload @resolve
}
// graphql playground
mutation {
editItem(
input: {
id: "gKTdECrXci"
fields: {
title: "New title"
}
}
) {
item {
title
}
}
}
Invoking the mutation results in this error:
"message": "Cannot return null for non-nullable field UpdateItemPayload.item."
Adding UpdateItemPayload (from Parse’s generated schema) to my custom schema does not change things:
# custom schema.graphql
type UpdateItemPayload {
# This is the updated object.
item: Item!
clientMutationId: String
}
However, if instead I short-circuit things and don’t use UpdateItemPayload
at all, my mutation work fine, and the item is updated correctly:
# custom schema.graphql
extend type Mutation {
editItem(input: UpdateItemInput!): Item! @resolve
}
// graphql playground
mutation {
editItem(
input: {
id: "gKTdECrXci"
fields: {
title: "New title"
}
}
) {
title
}
}
How can I get past this and be able to use UpdateItemPayload
? I would like my custom mutation format to match what Parse is using.