-
Notifications
You must be signed in to change notification settings - Fork 2k
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
parser: limit maximum number of tokens #3702
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Backport of graphql#3684 Motivation: Parser CPU and memory usage is linear to the number of tokens in a document however in extreme cases it becomes quadratic due to memory exhaustion. On my mashine it happens on queries with 2k tokens. For example: ``` { a a <repeat 2k times> a } ``` It takes 741ms on my machine. But if we create document of the same size but smaller number of tokens it would be a lot faster. Example: ``` { a(arg: "a <repeat 2k times> a" } ``` Now it takes only 17ms to process, which is 43 time faster. That mean if we limit document size we should make this limit small since it take only two bytes to create a token, e.g. ` a`. But that will hart legit documents that have long tokens in them (comments, describtions, strings, long names, etc.). That's why this PR adds a mechanism to limit number of token in parsed document. Also exact same mechanism implemented in graphql-java, see: graphql-java/graphql-java#2549 I also tried alternative approach of counting nodes and it gives slightly better approximation of how many resources would be consumed. However comparing to the tokens, AST nodes is implementation detail of graphql-js so it's imposible to replicate in other implementation (e.g. to count this number on a client). * Apply suggestions from code review Co-authored-by: Yaacov Rydzinski <yaacovCR@gmail.com> Co-authored-by: Yaacov Rydzinski <yaacovCR@gmail.com>
IvanGoncharov
added
the
PR: feature 🚀
requires increase of "minor" version number
label
Aug 16, 2022
Hi @IvanGoncharov, I'm @github-actions bot happy to help you with this PR 👋 Supported commandsPlease post this commands in separate comments and only one per comment:
|
cbush
pushed a commit
to mongodb/docs-realm
that referenced
this pull request
Mar 6, 2023
<h3>Snyk has created this PR to upgrade graphql from 16.3.0 to 16.6.0.</h3> :information_source: Keep your dependencies up-to-date. This makes it easier to fix existing vulnerabilities and to more quickly identify and fix newly disclosed vulnerabilities when they affect your project. <hr/> - The recommended version is **5 versions** ahead of your current version. - The recommended version was released **6 months ago**, on 2022-08-16. <details> <summary><b>Release notes</b></summary> <br/> <details> <summary>Package name: <b>graphql</b></summary> <ul> <li> <b>16.6.0</b> - <a href="https://snyk.io/redirect/github/graphql/graphql-js/releases/tag/v16.6.0">2022-08-16</a></br><h2>v16.6.0 (2022-08-16)</h2> <h4>New Feature <g-emoji class="g-emoji" alias="rocket" fallback-src="https://github.githubassets.com/images/icons/emoji/unicode/1f680.png">🚀</g-emoji></h4> <ul> <li><a href="https://snyk.io/redirect/github/graphql/graphql-js/pull/3645" data-hovercard-type="pull_request" data-hovercard-url="/graphql/graphql-js/pull/3645/hovercard">#3645</a> createSourceEventStream: introduce named arguments and deprecate positional arguments (<a href="https://snyk.io/redirect/github/yaacovCR">@ yaacovCR</a>)</li> <li><a href="https://snyk.io/redirect/github/graphql/graphql-js/pull/3702" data-hovercard-type="pull_request" data-hovercard-url="/graphql/graphql-js/pull/3702/hovercard">#3702</a> parser: limit maximum number of tokens (<a href="https://snyk.io/redirect/github/IvanGoncharov">@ IvanGoncharov</a>)</li> </ul> <h4>Bug Fix <g-emoji class="g-emoji" alias="lady_beetle" fallback-src="https://github.githubassets.com/images/icons/emoji/unicode/1f41e.png">🐞</g-emoji></h4> <ul> <li><a href="https://snyk.io/redirect/github/graphql/graphql-js/pull/3686" data-hovercard-type="pull_request" data-hovercard-url="/graphql/graphql-js/pull/3686/hovercard">#3686</a> Workaround for codesandbox having bug with TS enums (<a href="https://snyk.io/redirect/github/IvanGoncharov">@ IvanGoncharov</a>)</li> <li><a href="https://snyk.io/redirect/github/graphql/graphql-js/pull/3701" data-hovercard-type="pull_request" data-hovercard-url="/graphql/graphql-js/pull/3701/hovercard">#3701</a> Parser: allow 'options' to explicitly accept undefined (<a href="https://snyk.io/redirect/github/IvanGoncharov">@ IvanGoncharov</a>)</li> </ul> <h4>Committers: 2</h4> <ul> <li>Ivan Goncharov(<a href="https://snyk.io/redirect/github/IvanGoncharov">@ IvanGoncharov</a>)</li> <li>Yaacov Rydzinski (<a href="https://snyk.io/redirect/github/yaacovCR">@ yaacovCR</a>)</li> </ul> </li> <li> <b>16.5.0</b> - <a href="https://snyk.io/redirect/github/graphql/graphql-js/releases/tag/v16.5.0">2022-05-09</a></br><h2>v16.5.0 (2022-05-09)</h2> <h4>New Feature <g-emoji class="g-emoji" alias="rocket" fallback-src="https://github.githubassets.com/images/icons/emoji/unicode/1f680.png">🚀</g-emoji></h4> <ul> <li><a href="https://snyk.io/redirect/github/graphql/graphql-js/pull/3565" data-hovercard-type="pull_request" data-hovercard-url="/graphql/graphql-js/pull/3565/hovercard">#3565</a> Expose GraphQLErrorOptions type (<a aria-label="Pull request #3554" class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="1223840320" data-permission-text="Title is private" data-url="graphql/graphql-js#3554" data-hovercard-type="pull_request" data-hovercard-url="/graphql/graphql-js/pull/3554/hovercard" href="https://snyk.io/redirect/github/graphql/graphql-js/pull/3554">#3554</a>) (<a href="https://snyk.io/redirect/github/IvanGoncharov">@ IvanGoncharov</a>)</li> </ul> <h4>Committers: 1</h4> <ul> <li>Ivan Goncharov(<a href="https://snyk.io/redirect/github/IvanGoncharov">@ IvanGoncharov</a>)</li> </ul> </li> <li> <b>16.5.0-canary.pr.3686.d9ad8e3fd58929d38deea522d794a6b22d3244b5</b> - 2022-08-02 </li> <li> <b>16.4.0</b> - <a href="https://snyk.io/redirect/github/graphql/graphql-js/releases/tag/v16.4.0">2022-04-25</a></br><h2>v16.4.0 (2022-04-25)</h2> <h4>New Feature <g-emoji class="g-emoji" alias="rocket" fallback-src="https://github.githubassets.com/images/icons/emoji/unicode/1f680.png">🚀</g-emoji></h4> <ul> <li><a href="https://snyk.io/redirect/github/graphql/graphql-js/pull/3465" data-hovercard-type="pull_request" data-hovercard-url="/graphql/graphql-js/pull/3465/hovercard">#3465</a> refactor: use object for GraphQLError constructor (<a href="https://snyk.io/redirect/github/n1ru4l">@ n1ru4l</a>)</li> <li><a href="https://snyk.io/redirect/github/graphql/graphql-js/pull/3487" data-hovercard-type="pull_request" data-hovercard-url="/graphql/graphql-js/pull/3487/hovercard">#3487</a> feat: expose getArgumentValues (<a href="https://snyk.io/redirect/github/saihaj">@ saihaj</a>)</li> </ul> <h4>Bug Fix <g-emoji class="g-emoji" alias="lady_beetle" fallback-src="https://github.githubassets.com/images/icons/emoji/unicode/1f41e.png">🐞</g-emoji></h4> <ul> <li><a href="https://snyk.io/redirect/github/graphql/graphql-js/pull/3514" data-hovercard-type="pull_request" data-hovercard-url="/graphql/graphql-js/pull/3514/hovercard">#3514</a> GraphQLError: switch constructor overload order (<a href="https://snyk.io/redirect/github/glasser">@ glasser</a>)</li> </ul> <h4>Docs <g-emoji class="g-emoji" alias="memo" fallback-src="https://github.githubassets.com/images/icons/emoji/unicode/1f4dd.png">📝</g-emoji></h4> <details> <summary> 2 PRs were merged </summary> <ul> <li><a href="https://snyk.io/redirect/github/graphql/graphql-js/pull/3505" data-hovercard-type="pull_request" data-hovercard-url="/graphql/graphql-js/pull/3505/hovercard">#3505</a> correct outdated documentation (<a href="https://snyk.io/redirect/github/Ginhing">@ Ginhing</a>)</li> <li><a href="https://snyk.io/redirect/github/graphql/graphql-js/pull/3512" data-hovercard-type="pull_request" data-hovercard-url="/graphql/graphql-js/pull/3512/hovercard">#3512</a> Update documentation on deprecated formatError(..) (<a href="https://snyk.io/redirect/github/dwelch2344">@ dwelch2344</a>)</li> </ul> </details> <h4>Polish <g-emoji class="g-emoji" alias="nail_care" fallback-src="https://github.githubassets.com/images/icons/emoji/unicode/1f485.png">💅</g-emoji></h4> <details> <summary> 3 PRs were merged </summary> <ul> <li><a href="https://snyk.io/redirect/github/graphql/graphql-js/pull/3522" data-hovercard-type="pull_request" data-hovercard-url="/graphql/graphql-js/pull/3522/hovercard">#3522</a> tests(execution): add missing new lines (<a href="https://snyk.io/redirect/github/IvanGoncharov">@ IvanGoncharov</a>)</li> <li><a href="https://snyk.io/redirect/github/graphql/graphql-js/pull/3524" data-hovercard-type="pull_request" data-hovercard-url="/graphql/graphql-js/pull/3524/hovercard">#3524</a> tests(printSchema): test omitting schema of common names (<a href="https://snyk.io/redirect/github/IvanGoncharov">@ IvanGoncharov</a>)</li> <li><a href="https://snyk.io/redirect/github/graphql/graphql-js/pull/3537" data-hovercard-type="pull_request" data-hovercard-url="/graphql/graphql-js/pull/3537/hovercard">#3537</a> ESLint: disallow using node globals in src/tests (<a href="https://snyk.io/redirect/github/IvanGoncharov">@ IvanGoncharov</a>)</li> </ul> </details> <h4>Internal <g-emoji class="g-emoji" alias="house" fallback-src="https://github.githubassets.com/images/icons/emoji/unicode/1f3e0.png">🏠</g-emoji></h4> <details> <summary> 26 PRs were merged </summary> <ul> <li><a href="https://snyk.io/redirect/github/graphql/graphql-js/pull/3468" data-hovercard-type="pull_request" data-hovercard-url="/graphql/graphql-js/pull/3468/hovercard">#3468</a> ci: add stub action for canary releases on PRs (<a href="https://snyk.io/redirect/github/IvanGoncharov">@ IvanGoncharov</a>)</li> <li><a href="https://snyk.io/redirect/github/graphql/graphql-js/pull/3470" data-hovercard-type="pull_request" data-hovercard-url="/graphql/graphql-js/pull/3470/hovercard">#3470</a> ci: implement canary releases on PRs (<a href="https://snyk.io/redirect/github/IvanGoncharov">@ IvanGoncharov</a>)</li> <li><a href="https://snyk.io/redirect/github/graphql/graphql-js/pull/3472" data-hovercard-type="pull_request" data-hovercard-url="/graphql/graphql-js/pull/3472/hovercard">#3472</a> ci: remove NPM caching on canary release script (<a href="https://snyk.io/redirect/github/IvanGoncharov">@ IvanGoncharov</a>)</li> <li><a href="https://snyk.io/redirect/github/graphql/graphql-js/pull/3473" data-hovercard-type="pull_request" data-hovercard-url="/graphql/graphql-js/pull/3473/hovercard">#3473</a> ci: Pass 'GITHUB_TOKEN' to GitHub CLI (<a href="https://snyk.io/redirect/github/IvanGoncharov">@ IvanGoncharov</a>)</li> <li><a href="https://snyk.io/redirect/github/graphql/graphql-js/pull/3475" data-hovercard-type="pull_request" data-hovercard-url="/graphql/graphql-js/pull/3475/hovercard">#3475</a> ci: checkout repo in canary workflow (<a href="https://snyk.io/redirect/github/IvanGoncharov">@ IvanGoncharov</a>)</li> <li><a href="https://snyk.io/redirect/github/graphql/graphql-js/pull/3477" data-hovercard-type="pull_request" data-hovercard-url="/graphql/graphql-js/pull/3477/hovercard">#3477</a> ci: fix & cleanup script for modifying NPM package into canary (<a href="https://snyk.io/redirect/github/IvanGoncharov">@ IvanGoncharov</a>)</li> <li><a href="https://snyk.io/redirect/github/graphql/graphql-js/pull/3479" data-hovercard-type="pull_request" data-hovercard-url="/graphql/graphql-js/pull/3479/hovercard">#3479</a> ci: Add missing require to canary script (<a href="https://snyk.io/redirect/github/IvanGoncharov">@ IvanGoncharov</a>)</li> <li><a href="https://snyk.io/redirect/github/graphql/graphql-js/pull/3481" data-hovercard-type="pull_request" data-hovercard-url="/graphql/graphql-js/pull/3481/hovercard">#3481</a> ci: fix missing PR number in canary release workflow (<a href="https://snyk.io/redirect/github/IvanGoncharov">@ IvanGoncharov</a>)</li> <li><a href="https://snyk.io/redirect/github/graphql/graphql-js/pull/3483" data-hovercard-type="pull_request" data-hovercard-url="/graphql/graphql-js/pull/3483/hovercard">#3483</a> ci: fix missing PR number in canary release workflow (<a href="https://snyk.io/redirect/github/IvanGoncharov">@ IvanGoncharov</a>)</li> <li><a href="https://snyk.io/redirect/github/graphql/graphql-js/pull/3484" data-hovercard-type="pull_request" data-hovercard-url="/graphql/graphql-js/pull/3484/hovercard">#3484</a> ci: Moving GH Action template syntax to env variables (<a href="https://snyk.io/redirect/github/IvanGoncharov">@ IvanGoncharov</a>)</li> <li><a href="https://snyk.io/redirect/github/graphql/graphql-js/pull/3486" data-hovercard-type="pull_request" data-hovercard-url="/graphql/graphql-js/pull/3486/hovercard">#3486</a> ci: improve comment on canary releases (<a href="https://snyk.io/redirect/github/IvanGoncharov">@ IvanGoncharov</a>)</li> <li><a href="https://snyk.io/redirect/github/graphql/graphql-js/pull/3488" data-hovercard-type="pull_request" data-hovercard-url="/graphql/graphql-js/pull/3488/hovercard">#3488</a> ci: Extract branch publishing into separate workflow (<a href="https://snyk.io/redirect/github/IvanGoncharov">@ IvanGoncharov</a>)</li> <li><a href="https://snyk.io/redirect/github/graphql/graphql-js/pull/3489" data-hovercard-type="pull_request" data-hovercard-url="/graphql/graphql-js/pull/3489/hovercard">#3489</a> ci: use '.node-version' file to configure node version used for CI (<a href="https://snyk.io/redirect/github/IvanGoncharov">@ IvanGoncharov</a>)</li> <li><a href="https://snyk.io/redirect/github/graphql/graphql-js/pull/3491" data-hovercard-type="pull_request" data-hovercard-url="/graphql/graphql-js/pull/3491/hovercard">#3491</a> ci: use separate workflows for 'push' and 'pull_request' (<a href="https://snyk.io/redirect/github/IvanGoncharov">@ IvanGoncharov</a>)</li> <li><a href="https://snyk.io/redirect/github/graphql/graphql-js/pull/3493" data-hovercard-type="pull_request" data-hovercard-url="/graphql/graphql-js/pull/3493/hovercard">#3493</a> ci: remove unused 'workflow_id' input (<a href="https://snyk.io/redirect/github/IvanGoncharov">@ IvanGoncharov</a>)</li> <li><a href="https://snyk.io/redirect/github/graphql/graphql-js/pull/3496" data-hovercard-type="pull_request" data-hovercard-url="/graphql/graphql-js/pull/3496/hovercard">#3496</a> ci: fix deprecation of canary package (<a href="https://snyk.io/redirect/github/IvanGoncharov">@ IvanGoncharov</a>)</li> <li><a href="https://snyk.io/redirect/github/graphql/graphql-js/pull/3497" data-hovercard-type="pull_request" data-hovercard-url="/graphql/graphql-js/pull/3497/hovercard">#3497</a> ci: use environments to track deployments (<a href="https://snyk.io/redirect/github/IvanGoncharov">@ IvanGoncharov</a>)</li> <li><a href="https://snyk.io/redirect/github/graphql/graphql-js/pull/3502" data-hovercard-type="pull_request" data-hovercard-url="/graphql/graphql-js/pull/3502/hovercard">#3502</a> ci: fix deployments of npm & deno branches (<a href="https://snyk.io/redirect/github/IvanGoncharov">@ IvanGoncharov</a>)</li> <li><a href="https://snyk.io/redirect/github/graphql/graphql-js/pull/3503" data-hovercard-type="pull_request" data-hovercard-url="/graphql/graphql-js/pull/3503/hovercard">#3503</a> ci: Add '@ github-actions' bot (<a href="https://snyk.io/redirect/github/IvanGoncharov">@ IvanGoncharov</a>)</li> <li><a href="https://snyk.io/redirect/github/graphql/graphql-js/pull/3523" data-hovercard-type="pull_request" data-hovercard-url="/graphql/graphql-js/pull/3523/hovercard">#3523</a> github-actions-bot: replace 'octokit/request-action' action (<a href="https://snyk.io/redirect/github/IvanGoncharov">@ IvanGoncharov</a>)</li> <li><a href="https://snyk.io/redirect/github/graphql/graphql-js/pull/3525" data-hovercard-type="pull_request" data-hovercard-url="/graphql/graphql-js/pull/3525/hovercard">#3525</a> github-actions-bot: Fix collapsing of unrelated comments (<a href="https://snyk.io/redirect/github/IvanGoncharov">@ IvanGoncharov</a>)</li> <li><a href="https://snyk.io/redirect/github/graphql/graphql-js/pull/3530" data-hovercard-type="pull_request" data-hovercard-url="/graphql/graphql-js/pull/3530/hovercard">#3530</a> integrationTests/node: fix crash on Mac with M1 by using docker (<a href="https://snyk.io/redirect/github/IvanGoncharov">@ IvanGoncharov</a>)</li> <li><a href="https://snyk.io/redirect/github/graphql/graphql-js/pull/3534" data-hovercard-type="pull_request" data-hovercard-url="/graphql/graphql-js/pull/3534/hovercard">#3534</a> github-actions-bot: fix publishing of canary releases (<a href="https://snyk.io/redirect/github/IvanGoncharov">@ IvanGoncharov</a>)</li> <li><a href="https://snyk.io/redirect/github/graphql/graphql-js/pull/3536" data-hovercard-type="pull_request" data-hovercard-url="/graphql/graphql-js/pull/3536/hovercard">#3536</a> github-actions-bot: fix usage of NPM_CANARY_PR_PUBLISH_TOKEN (<a href="https://snyk.io/redirect/github/IvanGoncharov">@ IvanGoncharov</a>)</li> <li><a href="https://snyk.io/redirect/github/graphql/graphql-js/pull/3538" data-hovercard-type="pull_request" data-hovercard-url="/graphql/graphql-js/pull/3538/hovercard">#3538</a> github-actions-bot: fix reply on commands (<a href="https://snyk.io/redirect/github/IvanGoncharov">@ IvanGoncharov</a>)</li> <li><a href="https://snyk.io/redirect/github/graphql/graphql-js/pull/3543" data-hovercard-type="pull_request" data-hovercard-url="/graphql/graphql-js/pull/3543/hovercard">#3543</a> pass valid value to codecov config (<a href="https://snyk.io/redirect/github/is2ei">@ is2ei</a>)</li> </ul> </details> <h4>Dependency <g-emoji class="g-emoji" alias="package" fallback-src="https://github.githubassets.com/images/icons/emoji/unicode/1f4e6.png">📦</g-emoji></h4> <details> <summary> 2 PRs were merged </summary> <ul> <li><a href="https://snyk.io/redirect/github/graphql/graphql-js/pull/3485" data-hovercard-type="pull_request" data-hovercard-url="/graphql/graphql-js/pull/3485/hovercard">#3485</a> Update deps (<a href="https://snyk.io/redirect/github/IvanGoncharov">@ IvanGoncharov</a>)</li> <li><a href="https://snyk.io/redirect/github/graphql/graphql-js/pull/3533" data-hovercard-type="pull_request" data-hovercard-url="/graphql/graphql-js/pull/3533/hovercard">#3533</a> Update deps (<a href="https://snyk.io/redirect/github/IvanGoncharov">@ IvanGoncharov</a>)</li> </ul> </details> <h4>Committers: 7</h4> <ul> <li>David Glasser(<a href="https://snyk.io/redirect/github/glasser">@ glasser</a>)</li> <li>David Welch(<a href="https://snyk.io/redirect/github/dwelch2344">@ dwelch2344</a>)</li> <li>Ginhing(<a href="https://snyk.io/redirect/github/Ginhing">@ Ginhing</a>)</li> <li>Horie Issei(<a href="https://snyk.io/redirect/github/is2ei">@ is2ei</a>)</li> <li>Ivan Goncharov(<a href="https://snyk.io/redirect/github/IvanGoncharov">@ IvanGoncharov</a>)</li> <li>Laurin Quast(<a href="https://snyk.io/redirect/github/n1ru4l">@ n1ru4l</a>)</li> <li>Saihajpreet Singh(<a href="https://snyk.io/redirect/github/saihaj">@ saihaj</a>)</li> </ul> </li> <li> <b>16.4.0-canary.pr.2839.e3a8069cfaa6406186314b62aced6487f417a2e6</b> - 2022-04-27 </li> <li> <b>16.3.0</b> - <a href="https://snyk.io/redirect/github/graphql/graphql-js/releases/tag/v16.3.0">2022-01-26</a></br><h2>v16.3.0 (2022-01-26)</h2> <h4>New Feature <g-emoji class="g-emoji" alias="rocket" fallback-src="https://github.githubassets.com/images/icons/emoji/unicode/1f680.png">🚀</g-emoji></h4> <ul> <li><a href="https://snyk.io/redirect/github/graphql/graphql-js/pull/3454" data-hovercard-type="pull_request" data-hovercard-url="/graphql/graphql-js/pull/3454/hovercard">#3454</a> feat: allow providing an object to the GraphQLError constructor (<a href="https://snyk.io/redirect/github/n1ru4l">@ n1ru4l</a>)</li> <li><a href="https://snyk.io/redirect/github/graphql/graphql-js/pull/3464" data-hovercard-type="pull_request" data-hovercard-url="/graphql/graphql-js/pull/3464/hovercard">#3464</a> Expose <code>getArgumentValues</code> as public API (<a href="https://snyk.io/redirect/github/IvanGoncharov">@ IvanGoncharov</a>)</li> </ul> <h4>Bug Fix <g-emoji class="g-emoji" alias="lady_beetle" fallback-src="https://github.githubassets.com/images/icons/emoji/unicode/1f41e.png">🐞</g-emoji></h4> <ul> <li><a href="https://snyk.io/redirect/github/graphql/graphql-js/pull/3442" data-hovercard-type="pull_request" data-hovercard-url="/graphql/graphql-js/pull/3442/hovercard">#3442</a> Prevent Infinite Loop in OverlappingFieldsCanBeMergedRule (<a href="https://snyk.io/redirect/github/nicolaslt">@ nicolaslt</a>)</li> <li><a href="https://snyk.io/redirect/github/graphql/graphql-js/pull/3455" data-hovercard-type="pull_request" data-hovercard-url="/graphql/graphql-js/pull/3455/hovercard">#3455</a> OverlappingFieldsCanBeMerged: sort argument values before comparing (<a href="https://snyk.io/redirect/github/IvanGoncharov">@ IvanGoncharov</a>)</li> </ul> <h4>Docs <g-emoji class="g-emoji" alias="memo" fallback-src="https://github.githubassets.com/images/icons/emoji/unicode/1f4dd.png">📝</g-emoji></h4> <details> <summary> 2 PRs were merged </summary> <ul> <li><a href="https://snyk.io/redirect/github/graphql/graphql-js/pull/3269" data-hovercard-type="pull_request" data-hovercard-url="/graphql/graphql-js/pull/3269/hovercard">#3269</a> feat: setup docs site (<a href="https://snyk.io/redirect/github/saihaj">@ saihaj</a>)</li> <li><a href="https://snyk.io/redirect/github/graphql/graphql-js/pull/3437" data-hovercard-type="pull_request" data-hovercard-url="/graphql/graphql-js/pull/3437/hovercard">#3437</a> CONTRIBUTING.md: remove reference to Facebook bug bounty program (<a href="https://snyk.io/redirect/github/IvanGoncharov">@ IvanGoncharov</a>)</li> </ul> </details> <h4>Polish <g-emoji class="g-emoji" alias="nail_care" fallback-src="https://github.githubassets.com/images/icons/emoji/unicode/1f485.png">💅</g-emoji></h4> <details> <summary> 7 PRs were merged </summary> <ul> <li><a href="https://snyk.io/redirect/github/graphql/graphql-js/pull/3441" data-hovercard-type="pull_request" data-hovercard-url="/graphql/graphql-js/pull/3441/hovercard">#3441</a> UniqueArgumentDefinitionNamesRule: Improve tests (<a href="https://snyk.io/redirect/github/Cito">@ Cito</a>)</li> <li><a href="https://snyk.io/redirect/github/graphql/graphql-js/pull/3446" data-hovercard-type="pull_request" data-hovercard-url="/graphql/graphql-js/pull/3446/hovercard">#3446</a> Use 'eslint-plugin-simple-import-sort' to sort imports (<a href="https://snyk.io/redirect/github/IvanGoncharov">@ IvanGoncharov</a>)</li> <li><a href="https://snyk.io/redirect/github/graphql/graphql-js/pull/3447" data-hovercard-type="pull_request" data-hovercard-url="/graphql/graphql-js/pull/3447/hovercard">#3447</a> Fix index.ts files to be compatible with Typedoc (<a href="https://snyk.io/redirect/github/IvanGoncharov">@ IvanGoncharov</a>)</li> <li><a href="https://snyk.io/redirect/github/graphql/graphql-js/pull/3452" data-hovercard-type="pull_request" data-hovercard-url="/graphql/graphql-js/pull/3452/hovercard">#3452</a> validation-test.ts: various grammar fixes (<a href="https://snyk.io/redirect/github/spawnia">@ spawnia</a>)</li> <li><a href="https://snyk.io/redirect/github/graphql/graphql-js/pull/3457" data-hovercard-type="pull_request" data-hovercard-url="/graphql/graphql-js/pull/3457/hovercard">#3457</a> OverlappingFieldsCanBeMergedRule: simplify argument comparison (<a href="https://snyk.io/redirect/github/IvanGoncharov">@ IvanGoncharov</a>)</li> <li><a href="https://snyk.io/redirect/github/graphql/graphql-js/pull/3459" data-hovercard-type="pull_request" data-hovercard-url="/graphql/graphql-js/pull/3459/hovercard">#3459</a> blockString-tests: remove duplicate test, fix grammar (<a href="https://snyk.io/redirect/github/Cito">@ Cito</a>)</li> <li><a href="https://snyk.io/redirect/github/graphql/graphql-js/pull/3461" data-hovercard-type="pull_request" data-hovercard-url="/graphql/graphql-js/pull/3461/hovercard">#3461</a> visit: simplify handling of root node (<a href="https://snyk.io/redirect/github/IvanGoncharov">@ IvanGoncharov</a>)</li> </ul> </details> <h4>Internal <g-emoji class="g-emoji" alias="house" fallback-src="https://github.githubassets.com/images/icons/emoji/unicode/1f3e0.png">🏠</g-emoji></h4> <details> <summary> 5 PRs were merged </summary> <ul> <li><a href="https://snyk.io/redirect/github/graphql/graphql-js/pull/3433" data-hovercard-type="pull_request" data-hovercard-url="/graphql/graphql-js/pull/3433/hovercard">#3433</a> gh/actions: refactor out action to deploy branches (<a href="https://snyk.io/redirect/github/IvanGoncharov">@ IvanGoncharov</a>)</li> <li><a href="https://snyk.io/redirect/github/graphql/graphql-js/pull/3434" data-hovercard-type="pull_request" data-hovercard-url="/graphql/graphql-js/pull/3434/hovercard">#3434</a> gh/actions: remove 'npm dedupe' check since it unexpectadly do update (<a href="https://snyk.io/redirect/github/IvanGoncharov">@ IvanGoncharov</a>)</li> <li><a href="https://snyk.io/redirect/github/graphql/graphql-js/pull/3435" data-hovercard-type="pull_request" data-hovercard-url="/graphql/graphql-js/pull/3435/hovercard">#3435</a> gh/actions: run benchmark & diff-npm-package only on PRs (<a href="https://snyk.io/redirect/github/IvanGoncharov">@ IvanGoncharov</a>)</li> <li><a href="https://snyk.io/redirect/github/graphql/graphql-js/pull/3436" data-hovercard-type="pull_request" data-hovercard-url="/graphql/graphql-js/pull/3436/hovercard">#3436</a> gh/actions: make all cloned repo read-only (<a href="https://snyk.io/redirect/github/IvanGoncharov">@ IvanGoncharov</a>)</li> <li><a href="https://snyk.io/redirect/github/graphql/graphql-js/pull/3443" data-hovercard-type="pull_request" data-hovercard-url="/graphql/graphql-js/pull/3443/hovercard">#3443</a> ci/checkPackageLock: update only package-lock.json (<a href="https://snyk.io/redirect/github/IvanGoncharov">@ IvanGoncharov</a>)</li> </ul> </details> <h4>Dependency <g-emoji class="g-emoji" alias="package" fallback-src="https://github.githubassets.com/images/icons/emoji/unicode/1f4e6.png">📦</g-emoji></h4> <details> <summary> 4 PRs were merged </summary> <ul> <li><a href="https://snyk.io/redirect/github/graphql/graphql-js/pull/3438" data-hovercard-type="pull_request" data-hovercard-url="/graphql/graphql-js/pull/3438/hovercard">#3438</a> Update deps (<a href="https://snyk.io/redirect/github/IvanGoncharov">@ IvanGoncharov</a>)</li> <li><a href="https://snyk.io/redirect/github/graphql/graphql-js/pull/3444" data-hovercard-type="pull_request" data-hovercard-url="/graphql/graphql-js/pull/3444/hovercard">#3444</a> Update deps (<a href="https://snyk.io/redirect/github/IvanGoncharov">@ IvanGoncharov</a>)</li> <li><a href="https://snyk.io/redirect/github/graphql/graphql-js/pull/3462" data-hovercard-type="pull_request" data-hovercard-url="/graphql/graphql-js/pull/3462/hovercard">#3462</a> Update deps (<a href="https://snyk.io/redirect/github/IvanGoncharov">@ IvanGoncharov</a>)</li> <li><a href="https://snyk.io/redirect/github/graphql/graphql-js/pull/3463" data-hovercard-type="pull_request" data-hovercard-url="/graphql/graphql-js/pull/3463/hovercard">#3463</a> Update deps + fix 'npm audit' (<a href="https://snyk.io/redirect/github/IvanGoncharov">@ IvanGoncharov</a>)</li> </ul> </details> <h4>Committers: 6</h4> <ul> <li>Benedikt Franke(<a href="https://snyk.io/redirect/github/spawnia">@ spawnia</a>)</li> <li>Christoph Zwerschke(<a href="https://snyk.io/redirect/github/Cito">@ Cito</a>)</li> <li>Ivan Goncharov(<a href="https://snyk.io/redirect/github/IvanGoncharov">@ IvanGoncharov</a>)</li> <li>Laurin Quast(<a href="https://snyk.io/redirect/github/n1ru4l">@ n1ru4l</a>)</li> <li>Nicolas Lagoutte(<a href="https://snyk.io/redirect/github/nicolaslt">@ nicolaslt</a>)</li> <li>Saihajpreet Singh(<a href="https://snyk.io/redirect/github/saihaj">@ saihaj</a>)</li> </ul> </li> </ul> from <a href="https://snyk.io/redirect/github/graphql/graphql-js/releases">graphql GitHub release notes</a> </details> </details> <details> <summary><b>Commit messages</b></summary> </br> <details> <summary>Package name: <b>graphql</b></summary> <ul> <li><a href="https://snyk.io/redirect/github/graphql/graphql-js/commit/3a51ecade74a0198847e8b1ab1bcdc129485b79b">3a51eca</a> 16.6.0</li> <li><a href="https://snyk.io/redirect/github/graphql/graphql-js/commit/f0a0a4dadffe41dae541ab297f95997435b27c57">f0a0a4d</a> parser: limit maximum number of tokens (#3702)</li> <li><a href="https://snyk.io/redirect/github/graphql/graphql-js/commit/6c6508bd0d74587d7d264f6ab2258df5aeccc6af">6c6508b</a> Parser: allow 'options' to explicitly accept undefined (#3701)</li> <li><a href="https://snyk.io/redirect/github/graphql/graphql-js/commit/af8221a6504b66a95b9bc0c20935e8f18b23d7d2">af8221a</a> Workaround for codesandbox having bug with TS enums (#3686)</li> <li><a href="https://snyk.io/redirect/github/graphql/graphql-js/commit/59a73d64ee8a7a717c73e7dfdc1ea627a12a283e">59a73d6</a> createSourceEventStream: introduce named arguments and deprecate positional arguments (#3645)</li> <li><a href="https://snyk.io/redirect/github/graphql/graphql-js/commit/1f8ba95c662118452bd969c6b26ba4e9050c55da">1f8ba95</a> 16.5.0</li> <li><a href="https://snyk.io/redirect/github/graphql/graphql-js/commit/1112b4d58ec755dbde4f4734f3a4f8a6d6459681">1112b4d</a> Expose GraphQLErrorOptions type (#3554) (#3565)</li> <li><a href="https://snyk.io/redirect/github/graphql/graphql-js/commit/23dba4ed89634897155c422877d8192609e6d427">23dba4e</a> 16.4.0</li> <li><a href="https://snyk.io/redirect/github/graphql/graphql-js/commit/af64b671f36d469122f8a20b4aef9d65dbfe2374">af64b67</a> pass valid value to codecov config (#3543)</li> <li><a href="https://snyk.io/redirect/github/graphql/graphql-js/commit/16503cd1927da5f2928d4abfa84a64b3502bd6ba">16503cd</a> github-actions-bot: fix reply on commands (#3538)</li> <li><a href="https://snyk.io/redirect/github/graphql/graphql-js/commit/092655452ffac9195eb436e328e36ca792a9b1f3">0926554</a> ESLint: disallow using node globals in src/tests (#3537)</li> <li><a href="https://snyk.io/redirect/github/graphql/graphql-js/commit/4f062aaaa57b1bcf166d5e6d546c678ce2298433">4f062aa</a> github-actions-bot: fix usage of NPM_CANARY_PR_PUBLISH_TOKEN (#3536)</li> <li><a href="https://snyk.io/redirect/github/graphql/graphql-js/commit/a981dc61731a1e2e54e525ce7cfe4dc053a80a84">a981dc6</a> github-actions-bot: fix publishing of canary releases (#3534)</li> <li><a href="https://snyk.io/redirect/github/graphql/graphql-js/commit/bb70cbc93e9d3eb499798069da61cb303ebcd9b6">bb70cbc</a> Update deps (#3533)</li> <li><a href="https://snyk.io/redirect/github/graphql/graphql-js/commit/b38429f4d46b17f23d15406a2ca0d1eb201864b6">b38429f</a> integrationTests/node: fix crash on Mac with M1 by using docker (#3530)</li> <li><a href="https://snyk.io/redirect/github/graphql/graphql-js/commit/15040d02eb3c5ce2122c9329d26df5cde5ff5b3f">15040d0</a> Update documentation on deprecated formatError(..) (#3512)</li> <li><a href="https://snyk.io/redirect/github/graphql/graphql-js/commit/ff06428bcd0eb3a23f52480cb04d465157553afb">ff06428</a> refactor: use object for GraphQLError constructor (#3465)</li> <li><a href="https://snyk.io/redirect/github/graphql/graphql-js/commit/5f247e0e8f38b441b4445187d0c7f7170a417244">5f247e0</a> github-actions-bot: Fix collapsing of unrelated comments (#3525)</li> <li><a href="https://snyk.io/redirect/github/graphql/graphql-js/commit/faa42e2cb377cbc26c38f67b2f65891a61c22277">faa42e2</a> tests(printSchema): test omitting schema of common names (#3524)</li> <li><a href="https://snyk.io/redirect/github/graphql/graphql-js/commit/def26e6757a372762f102f7554204ba236bcf0b2">def26e6</a> github-actions-bot: replace 'octokit/request-action' action (#3523)</li> <li><a href="https://snyk.io/redirect/github/graphql/graphql-js/commit/f3248cd1a10c375f0a9a0d434dc6567a6cd54598">f3248cd</a> tests(execution): add missing new lines (#3522)</li> <li><a href="https://snyk.io/redirect/github/graphql/graphql-js/commit/6bcd241349d9a891149e524bd5046717f16798cb">6bcd241</a> ci: Add '@ github-actions' bot (#3503)</li> <li><a href="https://snyk.io/redirect/github/graphql/graphql-js/commit/e1726dfea66979bfe7ad1c0b0834613e4b6ce4b4">e1726df</a> GraphQLError: switch constructor overload order (#3514)</li> <li><a href="https://snyk.io/redirect/github/graphql/graphql-js/commit/da5723860e87c97831c02a1137e9431d96c14239">da57238</a> correct outdated documentation (#3505)</li> </ul> <a href="https://snyk.io/redirect/github/graphql/graphql-js/compare/f597c694339b7c488f05496806e404659f6ff955...3a51ecade74a0198847e8b1ab1bcdc129485b79b">Compare</a> </details> </details> <hr/> **Note:** *You are seeing this because you or someone else with access to this repository has authorized Snyk to open upgrade PRs.* For more information: <img src="https://api.segment.io/v1/pixel/track?data=eyJ3cml0ZUtleSI6InJyWmxZcEdHY2RyTHZsb0lYd0dUcVg4WkFRTnNCOUEwIiwiYW5vbnltb3VzSWQiOiI3ODgyYTEzNi0wNzEyLTQ0OGEtYmYyOC03NjYyNmNiNjBiNjEiLCJldmVudCI6IlBSIHZpZXdlZCIsInByb3BlcnRpZXMiOnsicHJJZCI6Ijc4ODJhMTM2LTA3MTItNDQ4YS1iZjI4LTc2NjI2Y2I2MGI2MSJ9fQ==" width="0" height="0"/> 🧐 [View latest project report](https://app.snyk.io/org/sandbox-2ba/project/9043c51f-3f0d-45c6-8455-b658274f2872?utm_source=github&utm_medium=referral&page=upgrade-pr) 🛠 [Adjust upgrade PR settings](https://app.snyk.io/org/sandbox-2ba/project/9043c51f-3f0d-45c6-8455-b658274f2872/settings/integration?utm_source=github&utm_medium=referral&page=upgrade-pr) 🔕 [Ignore this dependency or unsubscribe from future upgrade PRs](https://app.snyk.io/org/sandbox-2ba/project/9043c51f-3f0d-45c6-8455-b658274f2872/settings/integration?pkg=graphql&utm_source=github&utm_medium=referral&page=upgrade-pr#auto-dep-upgrades) <!--- (snyk:metadata:{"prId":"7882a136-0712-448a-bf28-76626cb60b61","prPublicId":"7882a136-0712-448a-bf28-76626cb60b61","dependencies":[{"name":"graphql","from":"16.3.0","to":"16.6.0"}],"packageManager":"npm","type":"auto","projectUrl":"https://app.snyk.io/org/sandbox-2ba/project/9043c51f-3f0d-45c6-8455-b658274f2872?utm_source=github&utm_medium=referral&page=upgrade-pr","projectPublicId":"9043c51f-3f0d-45c6-8455-b658274f2872","env":"prod","prType":"upgrade","vulns":[],"issuesToFix":[],"upgrade":[],"upgradeInfo":{"versionsDiff":5,"publishedDate":"2022-08-16T19:26:38.481Z"},"templateVariants":[],"hasFixes":false,"isMajorUpgrade":false,"isBreakingChange":false,"priorityScoreList":[]}) ---> --------- Co-authored-by: snyk-bot <snyk-bot@snyk.io>
This was referenced Jul 4, 2024
This was referenced Jul 12, 2024
This was referenced Jul 13, 2024
This was referenced Sep 11, 2024
This was referenced Sep 19, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Backport of #3684
Motivation: Parser CPU and memory usage is linear to the number of tokens in a
document however in extreme cases it becomes quadratic due to memory exhaustion.
On my mashine it happens on queries with 2k tokens.
For example:
It takes 741ms on my machine.
But if we create document of the same size but smaller number of
tokens it would be a lot faster.
Example:
Now it takes only 17ms to process, which is 43 time faster.
That mean if we limit document size we should make this limit small
since it take only two bytes to create a token, e.g.
a
.But that will hart legit documents that have long tokens in them
(comments, describtions, strings, long names, etc.).
That's why this PR adds a mechanism to limit number of token in
parsed document.
Also exact same mechanism implemented in graphql-java, see:
graphql-java/graphql-java#2549
I also tried alternative approach of counting nodes and it gives
slightly better approximation of how many resources would be consumed.
However comparing to the tokens, AST nodes is implementation detail of graphql-js
so it's imposible to replicate in other implementation (e.g. to count
this number on a client).
Co-authored-by: Yaacov Rydzinski yaacovCR@gmail.com
Co-authored-by: Yaacov Rydzinski yaacovCR@gmail.com