-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
GraphQL: null on GraphQL API layer should be converted to {__op: "Delete"} #7648
Comments
Thanks for opening this issue!
|
This is expected and well-known behavior. A |
So here following the official spec of GraphQL Spec ref: https://spec.graphql.org/June2018/#sec-Null-Value
Agree, but GraphQL API could not handle this diff, currently a developer with the GraphQL API can't know if the field is undefined or null, and graphql will never support this 2 values. Here the special case with the strict null check should be handled with the SDK or cloud code. But we need to let the developer unset the field via null value as expected by the official GraphQL Doc. And avoid a custom system with some Later if a developer need to know if the field value is really "null" (non sense in a graphql use case since the response will not change), we could introduce a query |
PR sent |
Interesting, looking at the GraphQL spec it seems you are correct. Reclassified this as a bug since the current behavior seems to violate the GraphQL specs. |
🎉 This change has been released in version 5.0.0-alpha.2 |
🎉 This change has been released in version 5.0.0-beta.1 |
🎉 This change has been released in version 5.0.0 |
New Issue Checklist
Issue Description
Currently
null
values used during GraphQL mutation are not transformed by the GraphQL layer, sonull
is directly saved into the database.null
in database could lead to unwanted behavior since query likeexists: false
will not resolve when the field has anull
value.Currently the GraphQL API has a lack of support to correctly unset fields. We should transform
null
toop Delete
Steps to reproduce
exists: false
Actual Outcome
null is saved into the DB
Expected Outcome
Null should transformed to undefined into the DB through the GraphQL API
Environment
alpha 5.0
Server
alpha 5.0
macOs
local
Database
mongo
4.4
local
The text was updated successfully, but these errors were encountered: