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

Unable to lint federation v2 schemas in v4 graphql-eslint #2812

Closed
4 tasks
InsidersByte opened this issue Dec 4, 2024 · 2 comments · Fixed by #2814
Closed
4 tasks

Unable to lint federation v2 schemas in v4 graphql-eslint #2812

InsidersByte opened this issue Dec 4, 2024 · 2 comments · Fixed by #2814

Comments

@InsidersByte
Copy link

InsidersByte commented Dec 4, 2024

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 editing 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

When attempting to lint a federation v2 schema with v4 of graphql-eslint that includes a federation directive e.g. @key. It fails with the error below.

Parsing error: Error while loading schema: Unknown directive "@key".

Unknown directive "@link".

It was possible to lint with v3 of graphql-eslint by setting parserOptions.schemaOptions.assumeValid to true, but it doesn't seem possible to do this in v4.

To Reproduce Steps to reproduce the behavior:

You can see an example failing schema here on the playground.

Expected behavior

To be able to lint federation v2 schemas.

Environment:

  • @graphql-eslint/eslint-plugin: 4.2.1

Additional context

I did see both of the following and while they are related it might not be the only way to resolve this issue hence I raised another one. Feel free to close if you think its appropriate:

@dimaMachina
Copy link
Collaborator

try 4.3.0-alpha-20241204113935-074a093b359d2947f263679eac8596958876a3b6

graphql-eslint should parse federation subgraphs without parse errors and you could even use known-directives rule which previously reported errors about unknown @link directive.

But for linting federation subgraphs schemas optional peer dependency @apollo/subgraph should be installed (you'll get runtime error in case of missing it)

@InsidersByte
Copy link
Author

I just tried it and it worked great!

Thanks

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

Successfully merging a pull request may close this issue.

2 participants