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

Number String or Int not allowed in Enum

Open dankolesnikov opened this issue 4 years ago • 5 comments

When defining an enum with a Number String like "11201" or an Int like11201, it will result in a schema validation error Names must match /^[_a-zA-Z][_a-zA-Z0-9]*$/ but "11201" does not.

Why are number strings or Int not allowed to be an enum? Thank you!

snippet:

enum IsoClass {
  11201
  11202
  11203
}
  • assignee(s): @acao
  • source:

Note: Action Item issues are reviewed and closed during Working Group meetings.

dankolesnikov avatar Oct 11 '21 16:10 dankolesnikov

https://github.com/graphql/graphiql/issues/586

dankolesnikov avatar Oct 11 '21 16:10 dankolesnikov

I have been facing the same issue. Would greatly appreciate this as a feature.

avibanerjee avatar Oct 11 '21 17:10 avibanerjee

Enum values conform to Name; some previous comments on requests like this:

  • https://github.com/graphql/graphql-spec/issues/779#issuecomment-701891496
  • https://github.com/graphql/graphql-spec/issues/508#issuecomment-426144240

benjie avatar Oct 11 '21 17:10 benjie

I don't think this was actually a GraphQL Spec WG Action Item so I'm going to remove the label.

benjie avatar Nov 28 '21 10:11 benjie

I think it's in-line with enum concept in programming languages like c# or java - enum is a list of names (!) or named int constants (in c#). I would better keep it this way, aligned with mainstream

rivantsov avatar May 05 '22 16:05 rivantsov