apollographql/eslint-plugin-graphql

Template placeholders cause validation errors

sirugh opened this issue · 0 comments

When we try to use a template placeholder in a graphql-tag template we get graphql validation errors:

  6:56  error    Syntax Error: Unexpected $  graphql/capitalized-type-name
  6:56  error    Syntax Error: Unexpected $  graphql/named-operations
  6:56  error    Syntax Error: Unexpected $  graphql/required-fields
  6:56  error    Syntax Error: Unexpected $  graphql/template-strings
const DEFAULT_FOO_SIZE = 4;

export const GET_FOOS_BY_SIZE = gql`
    query getFoos($size: Int = ${DEFAULT_FOO_SIZE}) {
        foos
    }
`;

When we replace ${DEFAULT_FOO_SIZE} with the literal 4 the validation errors cease.
I believe the eslint plugin sees the $ in ${ and interprets the following characters as a variable name. I would expect ${ and interpreted as a placeholder.

If this isn't the right place to report this, apologies!