GraphQL Enum doesnt work

I have…

  • [x] Checked the logs and have uploaded a log file and provided a link because I found something suspicious there. Please do not post the log file in the topic because very often something important is missing.

I’m submitting a…

  • [ ] Regression (a behavior that stopped working in a new release)
  • [x] Bug report
  • [ ] Performance issue
  • [ ] Documentation issue or request

Current behavior

When I select the Generate GraphQL Enum checkbox in the field editing section:


I would expect the schema to reflect it, however the schema for this field is still a String (or an array of Strings):

environments: [String!]

Expected behavior

I would expect the schema to be something like

environments: [Environments!]

Minimal reproduction of the problem

App: 1501

Environment

  • [ ] Self hosted with docker
  • [ ] Self hosted with IIS
  • [ ] Self hosted with other version
  • [x] Cloud version

Version: [VERSION]

Browser:

  • [ ] Chrome (desktop)
  • [ ] Chrome (Android)
  • [ ] Chrome (iOS)
  • [ ] Firefox
  • [ ] Safari (desktop)
  • [ ] Safari (iOS)
  • [ ] IE
  • [ ] Edge

Others:

1 Like

Hi,

it only works when all enum values are valid graphql names.

I do not remember the regex, but I remember:

  • Must start with letter (A-Za-z)
  • Cannot have “-”
1 Like

is it documented anywhere? i have a field which conforms to the rules you mentioned but it doesn’t seem to work anyway, perhaps you could provide the regex?

maybe instead it should strip out special characters and capitalise them? then the clients can resolve them back to their original version

I will add it to the hint.

The official spec is this one: https://spec.graphql.org/October2021/#sec-Names

maybe instead it should strip out special characters and capitalise them? then the clients can resolve them back to their original version

I tried that, but I had a few problems with it, that I don’t remember to be honest. I think it was the mapping from uppercase to the original names.

1 Like

Hey, me again, about the enums - do you not think that this spec is a little limiting? I would like to be able to produce an enum in the schema but for the UI I would use some nicer looking texts. Having to replace spaces with underlines makes it unusable, thoughts?

AS I said, I could not find a solution, but of course, sooner or later you have to say “It is not worth it, I am going to stop my investigation here”