Skip to content

fix(graphql): preserve PickType fields for dual-decorated inputs - #4007

Merged
kamilmysliwiec merged 1 commit into
nestjs:masterfrom
yudin-s:fix/picktype-dual-decorated-input
May 21, 2026
Merged

kamilmysliwiec merged 1 commit into
nestjs:masterfrom
yudin-s:fix/picktype-dual-decorated-input

Conversation

@yudin-s

@yudin-s yudin-s commented May 20, 2026 •

Copy link
Copy Markdown
Contributor

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Other... Please describe:

What is the current behavior?

PickType() can lose input fields when it is created from a dual-decorated source class with an explicit ObjectType decorator and the resulting class is also used as an input type. This produces an empty generated input type during schema generation.

Issue Number: Fixes #4006

What is the new behavior?

When PickType() receives an explicit decorator that differs from the source type decorator, the generated abstract class is registered with both decorators. This preserves the source input metadata for input inheritance while keeping the requested object metadata for object-type usage.

A regression test now covers a dual-decorated parent and child where PickType(..., ObjectType) is used as a GraphQL argument input and the generated input type keeps the picked nullable field.

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

Docs are not updated because this is a narrow regression fix for existing PickType() behavior.

Validated with:

yarn workspace @nestjs/graphql test:e2e tests/type-helpers/pick-type-double-register.spec.ts
yarn build
yarn oxlint packages/graphql/lib/type-helpers/pick-type.helper.ts packages/graphql/tests/type-helpers/pick-type-double-register.spec.ts
yarn prettier packages/graphql/lib/type-helpers/pick-type.helper.ts packages/graphql/tests/type-helpers/pick-type-double-register.spec.ts --check
git diff --check

@kamilmysliwiec
kamilmysliwiec merged commit ac5ed8b into nestjs:master May 21, 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.

PickType with ObjectType decorator on dual-decorated parent produces empty InputType in 13.4.0+

2 participants