-
Notifications
You must be signed in to change notification settings - Fork 60
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
Distinguish between null and missing in args #179
Comments
Sorry for the slow response. I have two ideas for how to solve this:
The second approach is a bit of a hack to implement outside of the library though. I haven't thought it through, but maybe it should be a native feature of OGS. |
I'm not very familiar with the GraphQL spec, but this discussion could be relevant: teamwalnut/graphql-ppx#26 (comment) If this is correct, the current behavior of raising an error when nullable variables are missing from the variables dictionary does not align with the spec. |
Can you elaborate on what you mean by this? And feel free to open a separate issue -- at first glance it does not appear related to this issue (though I could be mistaken) 😄 |
@andreas It's more of a question I guess, I don't know what behavior is correct and I'm curious whether a possible OGS solution to this issue would be relevant to my issue. query getUsers($first: Int, $after: Cursor) {
users(first: $first, after: $after) {
nodes {
id
}
}
} If I call this query with {
"errors": [
{
"message": "Missing variable `after`"
}
],
"data": null
} while In fact, this was the way After switching to During the subsequent discussion in the issue the author said he made this change to work around an issue with Sangria, but also that this change is compliant with the spec. Now I realize that my issue is about variables passed to the query, which is not this issue is about. But I'm still curious about your opinion on this, is this something I should attempt to solve on the client side, or at ocaml-graphql-server side? |
Is there some way to distinguish between the user passing in null and the user passing in nothing for an arg?
I have a use case for an update mutation that requires me to distinguish between missing and null. If the value was provided as null, then the underlying field in storage needs to be nulled out, but if the value is missing, then the underlying field should remain unchanged.
Example:
The text was updated successfully, but these errors were encountered: