Skip to content

fix: clone fields array in buildClassMetadata to prevent FieldResolver metadata leak into dual-type InputType - #1811

Open
MichalLytek with Copilot wants to merge 3 commits into
masterfrom
copilot/fix-fieldresolver-leak-inputtype
Open

fix: clone fields array in buildClassMetadata to prevent FieldResolver metadata leak into dual-type InputType#1811
MichalLytek with Copilot wants to merge 3 commits into
masterfrom
copilot/fix-fieldresolver-leak-inputtype

Conversation

Copilot AI commented May 11, 2026

Copy link
Copy Markdown
  • Add a @Mutation using DualClassInput as argument so the InputType is reachable in the schema
  • Assert DualClass ObjectType contains the computed field resolver
  • Assert DualClassInput InputType does NOT contain the computed field resolver
  • All 113 tests in resolvers.ts pass

Copilot AI changed the title [WIP] Fix FieldResolver metadata leak into InputType for dual-type classes fix: clone fields array in buildClassMetadata to prevent FieldResolver metadata leak into dual-type InputType May 11, 2026
Copilot AI requested a review from MichalLytek May 11, 2026 07:18
@MichalLytek
MichalLytek marked this pull request as ready for review May 11, 2026 08:45
Copilot AI review requested due to automatic review settings May 11, 2026 08:45

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a metadata-mutation bug in MetadataStorage that affects “dual-type” classes (decorated with both @ObjectType() and @InputType()), where later @FieldResolver processing could accidentally mutate a shared fields array and leak resolver fields into the InputType, leading to CannotDetermineGraphQLTypeError during schema build.

Changes:

  • Clone the cached fields array when assigning it to each class metadata definition to avoid cross-definition mutation.
  • Add a functional regression test that reproduces the dual-type + external @FieldResolver scenario and asserts schema building succeeds.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/metadata/metadata-storage.ts Prevents fields array reference sharing across object/input definitions by cloning on assignment.
tests/functional/resolvers.ts Adds a regression test ensuring external field resolvers don’t leak into @InputType() fields for dual-decorated classes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 2 additional findings.

Open in Devin Review

Comment thread tests/functional/resolvers.ts Outdated
@MichalLytek

Copy link
Copy Markdown
Owner

@copilot add new entry to the changelog.md, in the unreleased section

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.

Bug: FieldResolver metadata leaks into InputType for dual-type classes (shared fields array reference 2.0.0-rc.4)

3 participants