Graphcool / graphcool-framework

Apache License 2.0
1.77k stars 131 forks source link

Return related nodes in delete mutation #519

Open marktani opened 6 years ago

marktani commented 6 years ago

Originally reported by @Noitidart here.

Delete doesnt return related data

mutation {
  deleteVerify
  ( id:"cizdpqfq0iwqg0144xtrbosoy" )
  { id user { email } }
}

On success however it gives me null for user:

{
  "data": {
    "deleteVerify": {
      "id": "cizdpqfq0iwqg0144xtrbosoy",
      "user": null
    }
  }
}

Query works fine

The query for this works perfectly fine:

query {
  allVerifies
  (filter:{ id:"cizdpvvab1cr6013655of1man" })
  { id user { email } }
}
{
  "data": {
    "allVerifies": [
      {
        "id": "cizdpvvab1cr6013655of1man",
        "user": {
          "email": "blah@blah.com"
        }
      }
    ]
  }
}

So I'm confused why the mutation delete is not giving me the email.

usulpro commented 6 years ago

is it possible to query and mutate in single statement?

No, that's not possible.

My workaround is:

mutation {
  deleteVerify
  ( id:"cizdpqfq0iwqg0144xtrbosoy" )
  { id }
  user: updateUser(id: $userId) { email }
}
c10b10 commented 6 years ago

Looking at the schema generated by Graphcool, the output type of the deletion mutation for a node is that node type.

So isn't this supposed to be qualified as a Bug rather than a Feature? Doesn't that mean a mutation result is supposed to be able to include all of that Node's fields (including relational fields)?