XYZ - is an object, interface or union type field. Leaf selections on objects, interfaces, and unions without subfields are disallowed

Viewed 809

Running this Mutation GraphQL query:

mutation {
    addProduct (input: { name: "Salad Roll", description : "Tasty Salad Roll" })
}

I'm getting this error:

"errors": [ { "message": "addProduct is an object, interface or union type field. Leaf selections on objects, interfaces, and unions without subfields are disallowed.",

How do I fix it?

1 Answers

The solution is to return a value:

mutation {
    addProduct (input: { name: "Salad Roll", description : "Tasty Salad Roll" })
    {
        product
        {
        id
        }
    }
}
Related