Repository navigation
[visitor-plugin-common] fix: declare masked fragment types for unselected union members - #11047
Open
Tyagiquamar wants to merge 1 commit into
Open
Tyagiquamar wants to merge 1 commit into
Tyagiquamar wants to merge 1 commit into
Conversation
…cted union members Nested spreads referenced a member type that was dropped when that member selected no fields.
🦋 Changeset detectedLatest commit: a12ce20 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
This branch has not been deployed
This file contains hidden or 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
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.
Description
A fragment on a union or interface was dropping member types that selected no fields. With
inlineFragmentTypesset tomaskorcombine, a nested spread still referred to those per-member names, so the generated TypeScript did not compile (Cannot find name).SelectionSetToObjectnow keeps one type per member in that case. A member with no selected fields isRecord<PropertyKey, never>. The exported fragment type is the union of those members, which is the same shape already used when every member has a selection.Related #10920
Type of change
A masked or combined fragment that previously collapsed to only the selected union member is now a union that includes an empty type for each unselected member. That matches the names nested spreads already generated.
How Has This Been Tested?
pnpm exec prettier --checkonselection-set-to-object.ts,ts-documents.spec.ts, and the changeset. Result: all matched files use Prettier code style.pnpm exec vitest --no-watch packages/plugins/typescript/operations/tests/ts-documents.spec.tsinnode:24-bookwormwith pnpm 11.24.0. Result: 114 passed, including the new#10920case, which typechecks the generated output.pnpm exec eslint packages/plugins/other/visitor-plugin-common/src/selection-set-to-object.tson the host after an offline install. Result: exit 0.Test Environment:
node:24-bookworm) for Prettier and Vitest; Windows for ESLint@graphql-codegen/visitor-plugin-commonand@graphql-codegen/typescript-operationsfrom this branchChecklist: