Skip to content

When multiple different config blocks are used with different GraphQL configs, the first overrides others. #2962

Open

Description

@hedgepigdaniel

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 multiple config blocks are used with different GraphQL configs, for example:

To Reproduce Steps to reproduce the behavior:

{
  plugins: {
    '@graphql-eslint': graphqlPlugin,
  },
  languageOptions: {
    parser: graphqlPlugin.parser,
    parserOptions: {
      graphQLConfig: {
        schema: 'schema-1.graphqls',
        documents: 'documents-1/*.graphqls',
      },
    },
  },
  files: 'documents-1/*.graphqls',
},
{
  plugins: {
    '@graphql-eslint': graphqlPlugin,
  },
  languageOptions: {
    parser: graphqlPlugin.parser,
    parserOptions: {
      graphQLConfig: {
        schema: 'schema-2.graphqls',
        documents: 'documents-2/*.graphqls',
      },
    },
  },
  files: 'documents-2/*.graphqls',
}

In this example, documents-2/*.graphql files are incorrectly linted against schema-1, instead of schema-2. This happens because the global variable graphQLConfig is used once it has set, even if parserOptions specifies later a different configuration.

Expected behavior

When languageOptions is used to set a particular configuration, it should apply correctly to all files that that config block applies to.

Additional context
This is essentially the same problem as described in #2260. But the fix for that was specific to two rules, and did not fix the more general issue.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      ⌂ 换网址