Skip to content

Tracking issue - Enumeration values limited by GraphQL #7904

@derrickmehaffy

Description

@derrickmehaffy

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.

More will be shown below

Possible workarounds depending on the use case

  • Using relations such as oneWay with a storage model for the values (single select)
  • Using relations such as manyWay with 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)

To be very clear, we have no ETA on this, please do not reply asking for one.

Metadata

Metadata

Assignees

No one assigned

    Labels

    issue: enhancementIssue suggesting an enhancement to an existing featureseverity: lowIf the issue only affects a very niche base of users and an easily implemented workaround can solvesource: core:strapiSource is core/strapi packagesource: plugin:graphqlSource is plugin/graphql package

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions