From the spec:
GraphQL has a constant literal to represent enum input values. GraphQL string literals must not be accepted as an enum input and instead raise a query error.
Query variable transport serializations which have a different representation for non‐string symbolic values (for example, EDN) should only allow such values as enum input values. Otherwise, for most transport serializations that do not, strings may be interpreted as the enum input value with the same name.
In other words, when using an enum as an input, if you're using it as a literal value, like this:
Keys(input: { mode: test }) {
name
}
the enum value (test
in this case) cannot be quoted, unlike Strings literals, which must be surrounded by double quotes.
On the other hand, if you're using a variable to substitute an enum value, you'll set the value of the variable to a string, just like you would for a regular String value:
Keys(input: { mode: $mode }) {
name
}
// in your component...
variables: {
mode: 'test'
}
Because JSON doesn't include the concept of enum values, whenever we deal with a JSON context (for example, when declaring variables, or when returning the data
for our request), enum values are simply serialized as string values.
All that aside, if you're using Apollo as a client, whether you have to include the quotation marks or not should be irrelevant -- if you need to substitute the value for the mode
input field, you should be using variables to do so, in which case (as shown above), you would be passing in a string value regardless.
Keys(input: mode: test})
, GraphQL will have no problems resolvingtest
. However, I would like it to resolvetest
in quotes as"test"
. – Rebeccarebecka