Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generated client cannot distinguish not set and null value #2078

Open
brucegodden opened this issue Nov 28, 2024 Discussed in #2074 · 0 comments
Open

Generated client cannot distinguish not set and null value #2078

brucegodden opened this issue Nov 28, 2024 Discussed in #2074 · 0 comments

Comments

@brucegodden
Copy link

Discussed in #2074

Originally posted by brucegodden November 25, 2024
I am working on a GraphQL mutation for updating an object. I would like to say:

  • if an input property is not set then the object value is left alone;
  • if an input property is set then the object value is set to that value;
  • except that if the property is specified as null then the object value is cleared. (Only makes sense for optional properties, of course.)

This seems to me to be a reasonable GraphQL API definition. It is fairly straightforward to arrange to obey this behaviour in the implementation of the API.

However, the generated API client does not seem to distinguish between not set and null. Either you have to set a value in the constructor for the input type, presumably null if you don't have an actual value, or the value defaults to null if you don't explicitly set it.

Would it be unreasonable to ask for the generated client to be able to arrange to not include a property in the query input if the user did not specify a value for it? (Possibly only for optional properties.)

To cause further confusion, it looks like the conversion from the input type to the query input is ignoring any properties set to null, whether explicitly or not. (A common behaviour of Jackson and its ilk.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant