graphiql icon indicating copy to clipboard operation
graphiql copied to clipboard

Allow number strings for an Enum Type's possible values

Open davidianlandis opened this issue 9 years ago • 4 comments

Since the name of the Enum serializes as a string, can the name of an enum value not start with a number (as a string)?
In my case, I was trying to use '031' (to represent '031') as one of the values for a custom Enum Type.

The implementation I'm using allowed it without error, but graphiql failed my schema on the assertValidName check since it only allows underscore and letters.

davidianlandis avatar Aug 31 '17 21:08 davidianlandis

Can you try using process.env.GRAPHQL_NO_NAME_WARNING as described here ?

daxlab avatar Sep 02 '17 16:09 daxlab

I've come across this too. It sounds like it's a valid bug, as I haven't been able to find anything that says there are limitations around the enum naming convention.

dncrews avatar Feb 15 '18 19:02 dncrews

@davidianlandis @dncrews GraphQL require enum values to match [_A-Za-z][_0-9A-Za-z] RegExp: http://facebook.github.io/graphql/October2016/#sec-Enum-Value http://facebook.github.io/graphql/October2016/#Name

That means you cant use 031as an enum value. If you can't change enum value to something valid (e.g._031) you can use String` instead.

IvanGoncharov avatar Feb 16 '18 12:02 IvanGoncharov

if you come across the issue and think the spec group should the decision to not allow purely numerical enum values, please go to https://github.com/graphql/graphql-wg and open either an issue or a new PR.

acao avatar Jan 28 '21 15:01 acao