Skip to content
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

Nullable variables field in request payload #483

Open
elenigen opened this issue Jul 26, 2018 · 4 comments
Open

Nullable variables field in request payload #483

elenigen opened this issue Jul 26, 2018 · 4 comments
Labels
🤷‍♀️ Ambiguity An issue/PR which identifies or fixes spec ambiguity

Comments

@elenigen
Copy link

It looks like the specification is not clear if the client provides a request without variables, does the field "variables" should be assigned "null" or "{}" or both are valid?

Context:
In the altair tool, the default value is set to "{}" (without the double quotes) and in the graphql-java implementation, it's expecting a "null" value if not variables are needed. The result is, the queries are rejected on the server side, so does the server side is too stick or is it the client side which is providing the wrong value?

@IvanGoncharov
Copy link
Member

AFAIK, the spec doesn't prevent null or {} and there is only one relevant place on how variables are handled:
http://facebook.github.io/graphql/June2018/#CoerceVariableValues()

So de jure even { foo: "bar" } is valid.

@elenigen
Copy link
Author

What do you mean be

So de jure even

... but thanks, I think you answered my question:
Let coercedValues be an empty unordered Map.
I guess by empty, they mean {}, but I'm not understanding why they mention empty unordered Map, since it's empty there's nothing to sort?!

@IvanGoncharov
Copy link
Member

TL;DR; Current spec version doesn't enforce any particular format for variableValues

What do you mean be

@elenigen I mean that nothing in the current version of GraphQL Specification prevent any value.

Let coercedValues be an empty unordered Map.
I guess by empty, they mean {}, but I'm not understanding why they mention empty unordered Map, since it's empty there's nothing to sort?!

coercedValues is the result of coercion and variableValues is what you supply to GraphQL.
variableValues is used only in 3e & 3f and they executed only if:

  1. For each variableDefinition in variableDefinitions:

So with current spec text if you don't have any variableDefinition any value would work.

Moreover:

Let value be the value provided in variableValues for the name variableName.

There are no references to variableValues being object it just should match a name to a value in some way.

@leebyron leebyron added 🤷‍♀️ Ambiguity An issue/PR which identifies or fixes spec ambiguity and removed question labels Oct 2, 2018
@RubenGamarrarodriguez-tomtom
Copy link

RubenGamarrarodriguez-tomtom commented Jan 19, 2022

When using application/json' for the request. (Or if one is using GraphQL over HTTP, providing the header 'Content-Type: application/json'

The whole request has to be valid JSON.
{..., "variables": "{}" ...} Might be considered valid.
Where:
{..., "variables": {} ...} Might fail. Which I see as expected, meaning it seems to me as not a bug of the implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🤷‍♀️ Ambiguity An issue/PR which identifies or fixes spec ambiguity
Projects
None yet
Development

No branches or pull requests

4 participants