Like what we’re doing? Star us on GitHub!

GraphQL sometimes replacing hyphens and commas with underscores

sesons
4 weeks ago
14

Hello fellas, would anyone know why the value of something in gql has hyphens and commas replaced with underscores? This does not occur when accessing data with REST

image.png
image.png
  • jmikrut
    Payload Team
    4 weeks ago

    This is because GraphQL doesn't allow dashes



    nothing Payload can do there unfortunately. To keep parity, I would avoid using dashes in field names



    use camelCase instead



    or undrescores, either way

  • sesons
    4 weeks ago

    so just to clarify, is that just for strings that are prefixed with a hyphen? i.e. i just can't start a value with a -

  • jmikrut
    Payload Team
    4 weeks ago

    any hyphen at all, anywhere



    doesn't need to be prefixed



    my-field

    will be turned into

    my_field
  • sesons
    4 weeks ago

    sorry to clarify this is for the value of a field, not a field name in itself

  • jmikrut
    Payload Team
    4 weeks ago

    like a select field for example?



    yep, same thing applies there as well. select values / radio values are

    enum

    s in graphql



    and enums can't have dashes either

  • sesons
    4 weeks ago

    ah ok makes sense



    thank you

Open the post
Continue the discussion in Discord
Can't find what you're looking for?
Get help straight from the Payload team with an Enterprise License.Learn More