GraphQL sometimes replacing hyphens and commas with underscores

default discord avatar
sesonslast year
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

  • discord user avatar
    jmikrut
    last year

    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
    sesonslast year

    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
    last year

    any hyphen at all, anywhere



    doesn't need to be prefixed



    my-field

    will be turned into

    my_field
  • default discord avatar
    sesonslast year

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

  • discord user avatar
    jmikrut
    last year

    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
    sesonslast year

    ah ok makes sense



    thank you

Star on GitHub

Star

Chat on Discord

Discord

online

Can't find what you're looking for?

Get help straight from the Payload team with an Enterprise License.