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

Make the fragment matcher deterministic #10214

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

tgandrews
Copy link

Description

This exposes a new plugin option deterministic that when enabled will ensure that the fragment matcher will always return the same result for the same schema, no matter the order it is in the schema.

It does this by sorting the results so that they are always in the same order.

The default is false to maintain backwards compatibility.

Related # (issue)

Type of change

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

Ran this against a small private schema and one large private schema.

  • Test output is sorted without making schema changes
  • Tested output remains the same after multiple schema re-ordering edits

Test Environment:

  • OS: MacOS Sequoia 15.1.1
  • @graphql-codegen/core: 4.0.2
  • @graphql-codegen/fragment-matcher: This PR
  • NodeJS: v20.18.0

Checklist:

  • I have followed the CONTRIBUTING doc and the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

This exposes a new plugin option `deterministic` that when enabled will
ensure that the fragment matcher will always return the same result for
the same schema, no matter the order it is in the schema.

It does this by sorting the results so that they are always in the same
order.

The default is `false` to maintain backwards compatibility.

This fixes dotansimha#7367
Copy link

changeset-bot bot commented Dec 8, 2024

🦋 Changeset detected

Latest commit: 55ffbe0

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@graphql-codegen/fragment-matcher Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

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

Successfully merging this pull request may close these issues.

1 participant