Graphql-go: Whole object is null, when error returned with some value

Created on 18 Oct 2018  路  5Comments  路  Source: graph-gophers/graphql-go

I was trying to return a type/object with error, so that I can debug my error from front-end, but it seems when I return any value into error then the whole object always return as null :( but if I return error as nil then it return object's value.

problem

Most helpful comment

this is part of the GraphQL spec:

https://facebook.github.io/graphql/June2018/#sec-Data

If an error was encountered during the execution that prevented a valid response, the data entry in the response should be null.

All 5 comments

Same problem by me

https://github.com/graph-gophers/graphql-go/blob/995849d5bff2932ba449bea0c7cf0638d7f69f70/internal/exec/exec.go#L209

In fact, this is a tricky problem that is difficult to solve according to the current code implementation.

this is part of the GraphQL spec:

https://facebook.github.io/graphql/June2018/#sec-Data

If an error was encountered during the execution that prevented a valid response, the data entry in the response should be null.

@svanburen agree on resolving 1 instance, but this also occurs on returning a list and there I'm not sure if it should...

When you have a list of 10 items and 9 resolve correctly, and the tenth throws an error. Should you still be forced to give a null back while the 9 sub resolvers did produce a valid response?

@VincentVW https://graphql.github.io/graphql-spec/June2018/#example-90475 - I'd agree that you shouldn't be forced to give null back in that situation.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

saward picture saward  路  6Comments

estutzenberger picture estutzenberger  路  4Comments

tonyghita picture tonyghita  路  3Comments

LeeWong picture LeeWong  路  4Comments

AndreasBackx picture AndreasBackx  路  4Comments