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

Error loading schema causes ESLint to crash #1378

Closed
1 of 4 tasks
turbosheep44 opened this issue Jan 12, 2023 · 7 comments
Closed
1 of 4 tasks

Error loading schema causes ESLint to crash #1378

turbosheep44 opened this issue Jan 12, 2023 · 7 comments
Labels
kind/enhancement New feature or request stage/5-alpha-release-testing The pull request is merged, an alpha release is available, to be tested

Comments

@turbosheep44
Copy link

turbosheep44 commented Jan 12, 2023

Issue workflow progress

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


Description

A problem in the schema causes ESLint to outright crash, rather than outputting an error.

Reproduction

To reproduce, open this workspace and execute the command npm run lint.

Expected behavior

I expect ESLint to output an error that the type Carw does not exist in the usual manner.

Environment:

  • OS: Windows 10, Debian 11
  • @graphql-eslint/eslint-plugin: 3.14.3
  • Node.js: 16.14.2, 18.12.1

Additional context

This also causes problems with the ESLint VS Code extension. The ESLint processes crashes and does not restart, so all linting is lost and also an error alert is shown by VS Code.

@dimaMachina
Copy link
Owner

dimaMachina commented Jan 12, 2023

@turbosheep44 @Manivela I need help with testing new behaviour, please try the following alpha version 3.14.4-alpha-20230112232227-647789a

update:

or another solution n2 3.14.4-alpha-20230113010120-7556537

@dimaMachina dimaMachina added stage/5-alpha-release-testing The pull request is merged, an alpha release is available, to be tested kind/enhancement New feature or request labels Jan 12, 2023
@Manivela
Copy link

@B2o5T seems to be working on 3.14.4-alpha-20230112232227-647789a but not on 3.14.4-alpha-20230113010120-7556537

@dimaMachina
Copy link
Owner

@Manivela what exactly doesn't work for you on 3.14.4-alpha-20230113010120-7556537?
Because the plugin no longer crashes ESLint on both versions

@Manivela
Copy link

Manivela commented Jan 17, 2023

sorry to hijack this issue 😅 looks like my crashes were a combination of this issue #1091 and my installed graphql version (14.1.1) after upgrading my graphql version and using the terminal to run eslint everything works fine with both alphas and the current 3.14.3 version.

when I was running graphql14 through the terminal I could see this error message:
TypeError: Error while loading rule '@graphql-eslint/require-id-when-available': Error while loading schema: originalType.toConfig is not a function
while vscode output kept saying:
Error while loading rule '@graphql-eslint/require-id-when-available': Error while loading schema: Cannot read properties of undefined (reading 'major')
which led me here 🙈

I'm assuming graphql14 isn't supported so everything is working as expected.

@turbosheep44
Copy link
Author

@B2o5T Just tested with version 3.14.4-alpha-20230113010120-7556537. ESLint no longer crashes which is great, but the error is always reported as being at 0:0 and the error is reported in every file, even when it doesn't exist in that file :/

I have updated the reproduction environment to reflect the problem. Even though the mistake only exists in the car.graphql file, it prints as though the problem exists at line 0 in every file:

❯ npm run lint
$ eslint schema/*.graphql

/home/projects/github-ednqvs/schema/car.graphql
  0:0  error  Parsing error: [graphql-eslint] Error while loading schema: Unknown type "Carw". Did you mean "Car"?

/home/projects/github-ednqvs/schema/query.graphql
  0:0  error  Parsing error: [graphql-eslint] Error while loading schema: Unknown type "Carw". Did you mean "Car"?

/home/projects/github-ednqvs/schema/user.graphql
  0:0  error  Parsing error: [graphql-eslint] Error while loading schema: Unknown type "Carw". Did you mean "Car"?

✖ 3 problems (3 errors, 0 warnings)

@dimaMachina
Copy link
Owner

Even though the mistake only exists in the car.graphql file, it prints as though the problem exists at line 0 in every file:

Unfortunately, this is a downside and can't be fixed because we can't build a schema that contains validation errors, in this case, we aren't able to provide a GraphQL schema for rules that require it.

@dimaMachina
Copy link
Owner

closed by #1386

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement New feature or request stage/5-alpha-release-testing The pull request is merged, an alpha release is available, to be tested
Projects
None yet
Development

No branches or pull requests

3 participants