Graphql-go: Support for Null Values in mutations

Created on 15 May 2018  路  6Comments  路  Source: graph-gophers/graphql-go

According to the GraphQL spec, there should be a distinction between explicitly set nullvalues and just plain omitted values (spec here: http://facebook.github.io/graphql/draft/#sec-Null-Value).

It can be used to distinguish between ignoring a field and deleting the field value in a mutation fx.

Is there support for this already and I'm just missing it?

Most helpful comment

I'm also interested in this. An example would be an update mutation that updates only fields passed in the query (and some of them could be null). There seems to be no way to identify if particular argument was passed as null or simply omitted. Could you please suggest any workarounds?

All 6 comments

I am interested this as well.

It would be nice to support json.RawMessage for nullable fields in the schema and not require it to be a pointer..

or maybe use a struct tag to skip the runtime type checks against the schema?

I'll poke around and maybe work on a PR.

@neelance or @tonyghita any thoughts on this?

@derekpitt we had a pretty severe bug in our system, so I ended up forking and providing a pretty crude solution that enables you to add another argument to your resolver functions, that can tell you if a field was provided or not.

I'm also interested in this. An example would be an update mutation that updates only fields passed in the query (and some of them could be null). There seems to be no way to identify if particular argument was passed as null or simply omitted. Could you please suggest any workarounds?

I second a solution on this. I have tried 2 different graphql projects written on go now and they both do not support null vs attribute not there. It would be really nice since this library has a pretty nice interface.

This issue is not something that I am actively looking at. Indeed it is mentioned in the spec that null and a missing value should be treated differently. PRs are welcome.

430 resolved this

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bsr203 picture bsr203  路  6Comments

bsr203 picture bsr203  路  7Comments

jakubdal picture jakubdal  路  6Comments

vladimiroff picture vladimiroff  路  6Comments

JitinGuglani picture JitinGuglani  路  6Comments