Simplify your stack and build anything. Or everything.
Build tomorrow’s web with a modern solution you truly own.
Code-based nature means you can build on top of it to power anything.
It’s time to take back your content infrastructure.

GraphQL sometimes replacing hyphens and commas with underscores

default discord avatar
sesons2 years ago
6

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

  • discord user avatar
    jmikrut
    2 years 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

  • default discord avatar
    sesons2 years 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 -

  • discord user avatar
    jmikrut
    2 years ago

    any hyphen at all, anywhere



    doesn't need to be prefixed



    my-field

    will be turned into

    my_field
  • default discord avatar
    sesons2 years ago

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

  • discord user avatar
    jmikrut
    2 years 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

  • default discord avatar
    sesons2 years ago

    ah ok makes sense



    thank you

Star on GitHub

Star

Chat on Discord

Discord

online

Can't find what you're looking for?

Get dedicated engineering support directly from the Payload team.