Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Template placeholders cause validation errors #285

Open
sirugh opened this issue Sep 2, 2020 · 0 comments
Open

Template placeholders cause validation errors #285

sirugh opened this issue Sep 2, 2020 · 0 comments

Comments

@sirugh
Copy link

sirugh commented Sep 2, 2020

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant