question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Problem with setting operations property on parserOptions when no operations in .graphql files

See original GitHub issue

Issue workflow progress

Progress of the issue based on the Contributor Workflow

  • 1. The issue provides a reproduction available on GitHub, Stackblitz or CodeSandbox

Please make sure the graphql-eslint version under package.json matches yours.

  • 2. A failing test has been provided
  • 3. A local solution has been provided
  • 4. A pull request is pending review

Describe the bug

We don’t have operations defined inside of .graphql files. They are all defined in .ts and .tsx files. If I set my config as:

  overrides: [
    {
      files: ['*.ts', '*.tsx'],
      processor: '@graphql-eslint/graphql',
    },
    {
      files: ['*.graphql'],
      extends: ['plugin:@graphql-eslint/operations-recommended', 'plugin:@graphql-eslint/relay'],
      parserOptions: {
        operations: './src/**/*.{ts,tsx}',
        schema: '../api-server/src/schema.graphql',
      },
    },
  ],

then I get the following errors in each of the .tsx files

Screen Shot 2022-08-18 at 1 30 36 PM

If I remove the operations property from parserOptions, then I get the following error for a number of rules:

Error: Error while loading rule '@graphql-eslint/require-id-when-available': Rule `require-id-when-available` requires `parserOptions.operations` to be set and loaded. See https://bit.ly/graphql-eslint-operations for more info

I’m not sure how to proceed without running into errors or disabling a lot of rules.

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:2
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
takumiya081commented, Oct 11, 2022

@B2o5T I try it and works fine 🎉 thank you ❤️

2reactions
nikolaikcommented, Aug 31, 2022

I had a legacy .graphqlconfig taking precedence over parserOptions that cased similar issues like described in the original post. After adding the following parserOptions all was well:

parserOptions: {
  skipGraphQLConfig: true
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Issues · B2o5T/graphql-eslint - GitHub
Reload schema in eslint-server if file with schema was changed ... Problem with setting operations property on parserOptions when no operations in .graphql...
Read more >
Add CI job to run GraphQL linter (#344088) · Issues - GitLab
use the output as a setting for graphql-eslint plugin (should be defined on parserOptions.schema property; run the linter. In order to run the ......
Read more >
@graphql-eslint/eslint-plugin - npm
Apply this plugin to GraphQL definitions defined in code files. If you are defining GraphQL schema or GraphQL operations in code files, you'll ......
Read more >
graphql-eslint - Bountysource
Our graphql systems support an #import directive in graphql files to allow sharing ... Problem with setting operations property on parserOptions when no...
Read more >
Handling operation errors - Apollo GraphQL Docs
Apollo Client ignores partial data by default, but you can override this behavior by setting a GraphQL error policy. Network errors. These are...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found