-
-
Notifications
You must be signed in to change notification settings - Fork 9.2k
Description
Describe the bug
This is a tracking issue for all the various references to the limitations of the enumeration field. All other issues, feature requests, and discussions will be closed and redirected here.
Context
Currently within Strapi, the enumeration field is a literal usage of the definition of enumeration data type defined here in which generally speaking a boolean data type is also considered an enumeration type with the value options of true and false.
For Strapi, due to us supporting GraphQL, we have restricted the types of values that can be used based on the following regex provided by Facebook, whom built GraphQL:
Name :: /[_A-Za-z][_0-9A-Za-z]*/
GraphQL query documents are full of named things: operations, fields, arguments, directives, fragments, and variables. All names must follow the same grammatical form. Names in GraphQL are case‐sensitive. That is to say name, Name, and NAME all refer to different names. Underscores are significant, which means other_name and othername are two different names. Names in GraphQL are limited to this ASCII subset of possible characters to support interoperation with as many other systems as possible.
http://facebook.github.io/graphql/#sec-Names
Current behavior
Using the above provided regex /[_A-Za-z][_0-9A-Za-z]*/ values for enums are limited to:
- Must start with a letter, lower or upper OR and underscore
_ - May have an infinite sane length
- May only contain upper or lowercase letters, numbers, and underscores
Expected behavior
Requests from users (though not limited to, this will be updated over time)
- Spaces
- Dashes
- - Special characters for different languages
- Alternative symbols
Currently none of the above are allowed, and manually setting them via the model settings may work if you don't have the GraphQL plugin installed, but are not supported and you do so at your own risk until we find a valid replacement.
Related Issues, Feature requests, Discussions, and Forum threads
Please note, the below are not the limit and additional entries may be linked to this issue, you can find them referenced in the comments.
- Original Discussion (very long): https://github.com/strapi/strapi/discussions/4780
- Enum graphql/graphql-js#936 (comment)
- Enumerables don't allow list items with non-alphanumeric characters #4250
- Enumeration Field does not allow for special characters #3921
- Eumeration field special character causes GraphQL error. #3340
- [Improvement request] Content Type: Enumeration #2494
- Enum value with hyphen breaks #1698
- https://github.com/strapi/strapi/discussions/7208
- Allow '-' & '/' in enumeration type in content type builder #7896
- Content-Type builder doesn't allow specials chars in enum values #7873
- Unable to create list of numeric values. #7600
- Enumerated values with "/" character break the graphql plugin #7234
- Can't add some another languag character in ENUMERATION from Content-Type #6328
- Enum with multiple times the same value breaks #5343
More will be shown below
Possible workarounds depending on the use case
- Using relations such as
oneWaywith a storage model for the values (single select) - Using relations such as
manyWaywith a storage model for the values (multi select) - Use a standard enum that fits the regex and map these values out on your frontend (what is currently expected)