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

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

Open
4 tasks
cernst11 opened this issue Dec 1, 2023 · 6 comments · May be fixed by kamilkisiela/graphql-config#1418
Open
4 tasks

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

cernst11 opened this issue Dec 1, 2023 · 6 comments · May be fixed by kamilkisiela/graphql-config#1418
Labels
kind/bug Bug :-( upstream An issue that occurs in software related to the chain

Comments

@cernst11
Copy link

cernst11 commented Dec 1, 2023

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.

@dimaMachina
Copy link
Owner

Hi, could you create a reproduction, or share your schema?

@cernst11
Copy link
Author

cernst11 commented Dec 1, 2023

Hey @dimaMachina I am working on it, Accidentally submitted before wrapping up and I am editing it now

@cernst11 cernst11 changed the title Passing large schema in as string casues Passing large schema in as string causes pattern too long error Dec 1, 2023
@cernst11
Copy link
Author

cernst11 commented Dec 1, 2023

@dimaMachina I have updated the bug with a description. I will see if I can put a sandbox together as an example. Our schema cannot be shared but I think I can create a similar way to reproduce if it would help

@dimaMachina
Copy link
Owner

@cernst11 thank you, some reproduction will be very helpful

@cernst11
Copy link
Author

cernst11 commented Dec 4, 2023

Hey @dimaMachina I have created an example here. I simplified our code down to the bare minimum and generated a mock schema. I have also updated the original description

@dimaMachina
Copy link
Owner

dimaMachina commented Dec 4, 2023

@cernst11 so the error says Parsing error: [graphql-eslint] pattern is too long which goes from graphql-config's minimatch dependency

https://github.com/isaacs/minimatch/blob/ef8f2672bdbbf6a632ea815636659fb31b5169aa/src/assert-valid-pattern.ts#L1-L12

where value const MAX_PATTERN_LENGTH = 1024 * 64 is hardcoded to 65536, your schema SDL contains 73892 characters

We'll try to find a way to fix it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Bug :-( upstream An issue that occurs in software related to the chain
Projects
None yet
2 participants