7

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.

Roy Leibovitz
  • 579
  • 5
  • 16

1 Answers1

1

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"
      }
    }
  ]
}
Marco Daniel
  • 5,467
  • 5
  • 28
  • 36