Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 485
Jeremy Thompson Avatar asked Oct 18 '25 17:10

Jeremy Thompson


1 Answers

The solution is to return a value:

mutation {
    addProduct (input: { name: "Salad Roll", description : "Tasty Salad Roll" })
    {
        product
        {
        id
        }
    }
}
like image 112
Jeremy Thompson Avatar answered Oct 21 '25 07:10

Jeremy Thompson



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!