0

When I execute a mutation created by useMutation with react-relay, and do not explicitly set optional variables, Relay sets those optional variables to null in the request.

My GraphQL server (Apollo) is able to distinguish between undefined and null values. I tested this by sending a GraphQL request from a HTTP client and omitting optional values.

I did search the docs, code and GitHub issues and neither did I find a way to adjust this behavior nor a reasoning why Relay does this.

The only thing I found is that in the official GraphQL specification omission and null are intermingled:
Mutations - Support being more specific about null and omission in input types

Questions:

  • What is Relay's reasoning behind setting missing optional variables to null? Is it because Relay adheres to the GraphQL spec accurately? If yes, does that mean that my Apollo GraphQL server is not properly adhering to the GraphQL spec?
  • Is there a way to omit optional variables instead of sending null with Relay?

0 Answers0