null values in body are not passed through to graphql backend
See original GitHub issueThe Wundergraph operation looks like this:
mutation someUpdate($id: Int!, $name: String, $description: String, $icon: URL, $image: URL, $labels: [String!]) {
object: someUpdate(id: $id, name: $name, description: $description, icon: $icon, image: $image, labels: $labels)
{
id
}
}
I have the semantics that we can clear a value by sending an update with a null value. This is different to sending an update when some values are not set, which means don’t change the values not included in the call.
For example, in the below call, I want to clear the existing “name” attribute on the object.
--- ClientRequest start ---
POST /api/main/operations/someUpdate HTTP/1.1
Host: localhost:9991
Accept: */*
Content-Length: 23
Content-Type: application/json
User-Agent: curl/7.68.0
{"id": 0, "name": null}
--- ClientRequest end ---
--- DebugTransport ---
Request:
POST / HTTP/1.1
Host: localhost:8000
Accept: application/json
Content-Type: application/json
{"variables":{"id":0},"query":"mutation($id: Int!, $name: String, $description: String, $icon: URL, $image: URL, $labels: [String!]){object: someUpdate(id: $id, name: $name, description: $description, icon: $icon, image: $image, labels: $labels){id}}"}
Duration: 121 ms
Response:
HTTP/1.1 200 OK
Content-Length: 28
Content-Type: application/json
Date: Fri, 05 Aug 2022 04:52:27 GMT
Server: uvicorn
{"data":{"object":{"id":0}}}
--- DebugTransport
You can see by the above, the Wundergraph server removes the “name” attribute, as it is null. If I set it to something else, it works ok.
The desired behaviour is for the wundergraph server to pass through null-valued arguments.
Issue Analytics
- State:
- Created a year ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Why does a GraphQL query return null? - Stack Overflow
There's two common reasons your field or fields are resolving to null: 1) returning data in the wrong shape inside your resolver; and...
Read more >Using nullability in GraphQL
A field can either be nullable or non-null, and this tells you whether or not you could receive a null value when you...
Read more >Nulls in GraphQL: Cheatsheet - Hasura
Nullability in GraphQL is a controversial topic. Some say constant null checks are a nuisance, while others err on the side of paranoia....
Read more >error when processing queries with an empty request body ...
I think it's because query parameters are parsed when the request gets from WebonyxGraphqlMiddleware to GraphQL\Server\Helper->parsePsrRequest ...
Read more >Passing Arguments - GraphQL
The exclamation point in Int! indicates that numDice can't be null, which means we can skip a bit of validation logic to make...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Sounds reasonable to me, although the reason is not performance. In some cases, you don’t want to send nulls because the server handles them differently than empty fields, e.g. in a patch.
Hey @spetrunin nice find 😃