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

@graphql-tools/documents: Mutations should not be sorted as order matters (mutation fields run in series, one after the other) #6195

Open
3 of 4 tasks
martyganz opened this issue May 17, 2024 · 0 comments

Comments

@martyganz
Copy link
Contributor

martyganz commented May 17, 2024

Issue workflow progress

Progress of the issue based on the
Contributor Workflow

  • 1. The issue provides a reproduction available on Github, Stackblitz or CodeSandbox

    Make sure to fork this template and run yarn generate in the terminal.

    Please make sure the GraphQL Tools package versions 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

printExecutableGraphQLDocument sorts mutations by name whereas from the GraphQL spec the order of mutation matters, they do not run in parallel like queries, but in series. See: https://graphql.org/learn/queries/#multiple-fields-in-mutations

To Reproduce Steps to reproduce the behavior:

packages/documents/tests/print-executable-graphql-document.spec.ts add the following test:

test('should not sort a mutation as mutations run in series and order matters', () => {
const inputDocument = parse(/* GraphQL */ mutation A { c { f e d } b a });
const outputStr = printExecutableGraphQLDocument(inputDocument);
expect(outputStr).toMatchInlineSnapshot("mutation A { c { f e d } b a }");
});

Expected behavior

Mutations not to be sorted

Environment:

  • OS: MacOS
  • "@graphql-tools/documents@^1.0.0"::
  • NodeJS: LTS Iron (v20) - Now using node v20.12.2 (npm v10.5.0)

Additional context

Linked issue in graphql-code-generator: dotansimha/graphql-code-generator#9925
PR I made to graphql-code-generator to provide an alternative: dotansimha/graphql-code-generator#9926 - here I was asked to create a PR here ;)

Creating a PR here now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant