fix(@nestjs/graphql): stop double-registering PickType inputs#3959
Merged
kamilmysliwiec merged 1 commit intonestjs:masterfrom Apr 28, 2026
Merged
Conversation
PickType called the source class's `decoratorFactory({ isAbstract: true })`
unconditionally and then again inside the `else` branch when no custom
class decorator was supplied, registering the generated abstract class
twice. Each registration also pushed the metadata onto the global
`all.inputType` (or `all.objectType`) array, so a single `PickType(...)`
ended up in `getInputTypesMetadata()` twice and the input was processed
twice during schema generation. Drop the redundant call so the standard
path matches OmitType / PartialType.
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.
Summary
decoratorFactory({ isAbstract: true })(PickObjectType)call at the top ofPickType. The same factory was already invoked inside theelsebranch a few lines below when no custom class decorator was provided, so everyPickType(...)registered the generated abstract class twice.Bug
TargetMetadataCollection'sinputType/objectTypesetters alwayspushonto the canonicalall.inputType/all.objectTypearrays. Calling the decorator factory twice therefore added two entries for the same target, andgetInputTypesMetadata()returned duplicates which the schema generator then processed twice (andaddInputTypesMap.sets once, hiding the issue but doubling work and complicating debugging).OmitType,PartialTypeandIntersectionTypealready use the single-call pattern that this PR alignsPickTypewith.Test plan
tests/type-helpers/pick-type-double-register.spec.ts(fails on master; passes after the fix).tests/plugin/type-helpers/**suite still passes.