Skip to content

Passing large schema in as string causes pattern too long error  #2046

@cernst11

Description

@cernst11

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


Describe the bug

When passing a large schema of over 8kb as a string instead of file path the loader attempts to pattern match the raw string and will throw and eslint pattern too long error.

To Reproduce Steps to reproduce the behavior:

Programatically extend and call the ESLint class and load the schema as a string into parserOptions. Next use the lintText method of the class to lint the GraphQL schema subset against the entire schema. Here an error will be thrown about the pattern being too long.

An example can be found and ran here. To run the example in the terminal run npm start

From here the following error message will be displayed

[
  {
    ruleId: null,
    fatal: true,
    severity: 2,
    message: 'Parsing error: [graphql-eslint] pattern is too long',
    line: undefined,
    column: undefined,
    nodeType: null
  }
]

Environment:

  • OS: Linux/MacOS
  • @graphql-eslint/eslint-plugin: 3.20.1
  • Node.js:

Additional context

This appears to be worked around in version 4 of the linter here by building the schema differently in the browser for use in the playground.

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugBug :-(stage/6-releasedThe issue has been solved on a released version of the libraryupstreamAn issue that occurs in software related to the chain

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions