graphql-over-http icon indicating copy to clipboard operation
graphql-over-http copied to clipboard

GraphQL request optional parameters

Open dariuszkuc opened this issue 1 year ago • 1 comments

Request parameter section currently specifies

Note: Specifying null in JSON (or equivalent values in other formats) as values for optional request parameters is equivalent to not specifying them at all.

I believe the above is incorrect as there is a semantic difference between

  • this parameter has a null (aka explicitly defined) value

vs

  • this parameter is not specified (aka undefined)

We had few requests for this functionality in graphql-kotlin (e.g. https://github.com/ExpediaGroup/graphql-kotlin/issues/783) and support it since the 4.x release. TLDR this is similar to undefined vs null value in Javascript (or wrapping value/null value in Optional in Java).

dariuszkuc avatar Aug 15 '22 20:08 dariuszkuc

@dariuszkuc We're talking about the direct values of request parameters here (query, operationName, variables, extensions), not argument/input field values during GraphQL execution. It's saying that:

{
  query: "{__typename}",
  operationName: null,
  variables: null,
  extensions: null
}

is equivalent to:

{
  query: "{__typename}"
}

benjie avatar Aug 16 '22 10:08 benjie

Gotcha. Thanks for clarifying.

dariuszkuc avatar Aug 16 '22 12:08 dariuszkuc