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

Excluded the __typename from the root node of subscriptions when using addTypenameSelectionDocumentTransform with documentTransforms #9889

Merged
merged 5 commits into from Mar 27, 2024

Conversation

Sojaner
Copy link
Contributor

@Sojaner Sojaner commented Feb 29, 2024

Description

The __typename should not be added to the root node of a subscription when using addTypenameSelectionDocumentTransform with documentTransforms since a single root node is expected and the code generator fails because of that (refer to the specification).

Related # (issue)

#9888

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Sandbox:

Issue Sandbox

How Has This Been Tested?

The fix is also included in the issue sandbox. The code can be run in 3 setups for testing:

  1. yarn generate which doesn't use the document transformer and works fine
  2. yarn generate --add-typenames which uses the current faulty document transformer and fails
  3. yarn generate --add-fixed-typenames which uses my fixed version of the document transformer and works fine

Test Environment:

  • OS: Windows
  • @graphql-codegen/client-preset: 4.2.4
  • NodeJS: 20.11.1

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

The __typename should not be added to the root node of a subscription since a single root node is expected and the code generator fails because of that
Copy link

changeset-bot bot commented Feb 29, 2024

🦋 Changeset detected

Latest commit: 522de24

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/client-preset 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

@n1ru4l
Copy link
Collaborator

n1ru4l commented Feb 29, 2024

@Sojaner Can you please add a test for this?

@Sojaner
Copy link
Contributor Author

Sojaner commented Feb 29, 2024

Done @n1ru4l! :)

@n1ru4l
Copy link
Collaborator

n1ru4l commented Mar 4, 2024

@Sojaner can you please take care of the failing CI?

@Sojaner
Copy link
Contributor Author

Sojaner commented Mar 4, 2024

@n1ru4l can you run the checks again?

@n1ru4l n1ru4l merged commit cd60e14 into dotansimha:master Mar 27, 2024
11 of 13 checks passed
@Sojaner Sojaner deleted the patch-1 branch March 27, 2024 12:51
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