Skip to content

fix(@nestjs/graphql): stop double-registering PickType inputs#3959

Merged
kamilmysliwiec merged 1 commit intonestjs:masterfrom
yogeshwaran-c:fix/pick-type-double-register
Apr 28, 2026
Merged

fix(@nestjs/graphql): stop double-registering PickType inputs#3959
kamilmysliwiec merged 1 commit intonestjs:masterfrom
yogeshwaran-c:fix/pick-type-double-register

Conversation

@yogeshwaran-c
Copy link
Copy Markdown
Contributor

Summary

  • Drop the redundant decoratorFactory({ isAbstract: true })(PickObjectType) call at the top of PickType. The same factory was already invoked inside the else branch a few lines below when no custom class decorator was provided, so every PickType(...) registered the generated abstract class twice.

Bug

TargetMetadataCollection's inputType/objectType setters always push onto the canonical all.inputType / all.objectType arrays. Calling the decorator factory twice therefore added two entries for the same target, and getInputTypesMetadata() returned duplicates which the schema generator then processed twice (and addInputTypes Map.sets once, hiding the issue but doubling work and complicating debugging).

OmitType, PartialType and IntersectionType already use the single-call pattern that this PR aligns PickType with.

Test plan

  • New regression test tests/type-helpers/pick-type-double-register.spec.ts (fails on master; passes after the fix).
  • tests/plugin/type-helpers/** suite still passes.

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.
@kamilmysliwiec kamilmysliwiec merged commit 9bbdf39 into nestjs:master Apr 28, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants