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

Cannot read properties of undefined (reading 'parserServices') #2569

Open
4 tasks
waynezhang1995 opened this issue Sep 17, 2024 · 1 comment
Open
4 tasks

Comments

@waynezhang1995
Copy link

waynezhang1995 commented Sep 17, 2024

Issue workflow progress

We are on @graphql-eslint/[email protected].

This is our eslintrc

 files: ['*.graphql'],
 parser: '@graphql-eslint/eslint-plugin',
 plugins: ['@graphql-eslint'],
 rules: {
       ....

.graphqlrc.yml

schema:
    - internal/graph/schema/**/*.graphql
    - scripts/**/*.graphql

the above error is coming from

function requireGraphQLSchemaFromContext(ruleId, context) {
  const { schema } = context.sourceCode.parserServices;
  if (!schema)
    throw new Error(
      `Rule \`${ruleId}\` requires graphql-config \`schema\` field to be set and loaded. See https://the-guild.dev/graphql/config/docs/user/schema for more info`
    );
  return schema;
}

and interestingly, if we change context.sourceCode to context.getSourceCode() everything starts working normally.

Appreciate any helps. Thanks

Progress of the issue based on the
Contributor Workflow

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

    For example, you can start off by editng the
    'basic' example on Stackblitz.

    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

To Reproduce Steps to reproduce the behavior:

Expected behavior

Environment:

  • OS:
  • @graphql-eslint/eslint-plugin:
  • Node.js:

Additional context

@alecmev
Copy link

alecmev commented Sep 21, 2024

Similar issue for us, but with documents. getSourceCode() doesn't seem to help either. Sprinkled some console.logs, and looks like the wrong graphql.config.* is being loaded/used. It's a monorepo and we have more than one, and one of them doesn't have documents, because there aren't any in that particular package, only schemas.

Appears to happen only via LSP (in VSCode), not CLI.

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

2 participants