question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

null values in body are not passed through to graphql backend

See original GitHub issue

The 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:open
  • Created a year ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
jensneusecommented, Aug 5, 2022

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.

0reactions
jensneusecommented, Dec 22, 2022

Hey @spetrunin nice find 😃

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found