graphql-spec icon indicating copy to clipboard operation
graphql-spec copied to clipboard

Clarify allowed values for variables

Open Kestrer opened this issue 5 years ago • 1 comments

The GraphQL spec doesn't mention the restrictions on variable types. For example:

query($value: SomeScalar) {
    # ...
}

And in variables:

{ "value": { "foo-bar": 5 } }

Is this allowed? foo-bar is not a valid Name and so the data can't be represented inline, but scalars can represent any value. I don't think the GraphQL spec actually clarifies about this anywhere.

Kestrer avatar Oct 02 '20 17:10 Kestrer

Yes this is permitted, it is supported by the reference implementation, and there are common scalars that use it such as the JSON scalar. Older versions of GraphiQL could not validate this in the variables tray, it would always appear invalid (though it would work fine when you execute the operation), I’m not sure if that’s been resolved.

benjie avatar Oct 02 '20 22:10 benjie