encodeEnumValue incorrectly prepends 2 underscores when it should only be one

Created on 18 July 2024, 4 months ago
Updated 29 July 2024, 4 months ago

Problem/Motivation

GraphQL doesn't allow for stuff to start with a number, the correct fix is to append a single underscore, but EnumValues appear to get appended with 2 underscores which should only be used for introspection and causes a validation error and any loading of the schema via explorer or voyager to crash.

Steps to reproduce

Probably many different ways, but I encountered this bug with an image style with a machine name of 350x115, which got converted to __350x115

Proposed resolution

Simple helper function change to add 1 underscore instead of 2.

Remaining tasks

🐛 Bug report
Status

Active

Version

1.0

Component

Code

Created by

🇨🇦Canada smccabe

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @smccabe
  • Merge request !13Update EntitySchemaHelper.php → (Open) created by smccabe
  • Pipeline finished with Canceled
    4 months ago
    Total: 120s
    #228328
  • Pipeline finished with Failed
    4 months ago
    Total: 192s
    #228330
  • 🇨🇦Canada smccabe

    Hmm.. it looks like use cases that already start with underscores need to be supported and items need to be both encoded and decoded

    123 -> _123 -> 123
    _123 -> _123 -> _123

    So using just a simple underscore it's impossible to determine if it was their already or not. Would it make the most sense to use something like `num_` or even `coreSchemaNumber_`?

  • 🇨🇭Switzerland dulnan

    Yeah exactly, it's quite tricky to fix. I guess prefixing it with "coreSchemaNumber_" would be the safest (since its very unlikely to clash with anything else). But it's quite verbose. I think "GQL_ENUM_" could also work, it's a bit shorter. What do you think?

Production build 0.71.5 2024