Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

@graphql-eslint/eslint-plugin "parserOptions.schema" error

We are developing micro-services in NestJS-typescript.

Each of them exposes a GraphQL schema. In order to expose a single graph, we are using a federation service, also in NestJS.

I was trying to integrate with '@graphql-eslint/eslint-plugin'.

The plugin's roles are divided into 2:

  1. Roles that don't have any requirements - work great.
  2. Roles that require schema/operation file - failure.

Section 2# roles require additional information regarding the schema files. As I said before, there are many schema & operation files that are located across the monorepo.

As mentioned in the documentation, in order to allow those roles the "parserOptions.schema" should be defined. No matter what I have done, I am failing to set the field and I get the following error:

Error: Rule 'unique-argument-names' requires 'parserOptions.schema' to be set and schema to be loaded. See https://github.com/dotansimha/graphql-eslint#extended-linting-rules-with-graphql-schema for more info

In my POV, I just want the linter to access all of the .graphql files across the whole project and I have no clue why is this not working and why this field is required at all since I have already defined the linter to lint only *.graphql files.

like image 756
Roy Leibovitz Avatar asked Jul 04 '26 19:07

Roy Leibovitz


1 Answers

I experienced the same issue and got around it by setting the parserOptions.schema to all .graphql files.

The .eslintrc.json file looks something like this:

{
  "overrides": [
    {
      "files": [
        "*.graphql"
      ],
      "plugins": [
        "@graphql-eslint"
      ],
      "parser": "@graphql-eslint/eslint-plugin",
      "parserOptions": {
        "schema":"./**/*.graphql"
      },
      "rules": {
        "@graphql-eslint/known-type-names": "error"
      }
    }
  ]
}
like image 128
Marco Daniel Avatar answered Jul 06 '26 09:07

Marco Daniel