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

add useGraphqlPrint & removeClientSpecificFields options to persisted… #9926

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

Conversation

martyganz
Copy link

@martyganz martyganz commented Apr 15, 2024

… documents in client-preset

🚨 IMPORTANT: Please do not create a Pull Request without creating an issue first.

Any change needs to be discussed before proceeding. Failure to do so may result in the rejection of the pull request.

Description

Adds two options to trusted documents codegen:

 persistedDocuments: {
          useGraphqlPrint: true
          removeClientSpecificFields: true
        }
  • useGraphqlPrint: boolean (default: false) - Wether to use print from graphql to convert the DocumentNode to string or to use the default: @graphql-tools/documents printExecutableGraphQLDocument
  • removeClientSpecificFields: boolean (default: true) - Remove client specific fields from the DocumentNode

I've added both to be backwards compatible with what is currently in place, thus not having a breaking change but open to suggestions.

It's related to below bug where using the @graphql-tools/documents print actually breaks our schema because it changes the order of fields within a mutation (where for us the order is actually important). This will allow us to fix it but if it is an actual bug which could affect more people it is probably better to change the printExecutable to graphql's print.

Related #9925

Type of change

Please delete options that are not relevant.

  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update

Screenshots/Sandbox (if appropriate/relevant):

Adding links to sandbox or providing screenshots can help us understand more about this PR and take action on it as appropriate

How Has This Been Tested?

yarn test packages/presets/client/tests/client-preset.spec.ts --watch

    1. Build locally and symlinked into our project
    1. Generated trusted documents and verified output manually

Added unit tests

Test Environment:

  • OS: MacOS
  • @graphql-codegen/...: latest
  • NodeJS: v18 (lts/hydrogen) & v20 (lts/iron)

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

Further comments

First PR here so open to any and all comments, feedback etc.

Copy link

changeset-bot bot commented Apr 15, 2024

⚠️ No Changeset found

Latest commit: 03503ca

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@martyganz martyganz marked this pull request as ready for review April 16, 2024 12:17
@martyganz martyganz changed the title WIP - add useGraphqlPrint & removeClientSpecificFields options to persisted… add useGraphqlPrint & removeClientSpecificFields options to persisted… Apr 16, 2024
@n1ru4l
Copy link
Collaborator

n1ru4l commented Apr 29, 2024

@martyganz It seems like the fix for the ordering should be performed within @graphql-tools/documents? Would you be open to send a pull request for fixing that there?

@n1ru4l
Copy link
Collaborator

n1ru4l commented Apr 29, 2024

@martyganz Also, please avoid sending different features in a single pull request. The useGraphqlPrint and removeClientSpecificFields are not related.

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.

None yet

2 participants