fix(graphql,apollo): ensures extensions are added to resolved fields#3779
Open
thiagomini wants to merge 1 commit intonestjs:masterfrom
Open
fix(graphql,apollo): ensures extensions are added to resolved fields#3779thiagomini wants to merge 1 commit intonestjs:masterfrom
thiagomini wants to merge 1 commit intonestjs:masterfrom
Conversation
thiagomini
commented
Jan 2, 2026
| await app.close(); | ||
| }); | ||
|
|
||
| it('Adds extensions to resolved field', async () => { |
Contributor
Author
There was a problem hiding this comment.
Note: I've asserted that this test fails without the changed I made to the type-metadata.storage
thiagomini
commented
Jan 2, 2026
| let objectOrInterfaceTypeField = | ||
| objectOrInterfaceTypeMetadata.properties.find( | ||
| (fieldDef) => fieldDef.name === item.methodName, | ||
| (fieldDef) => fieldDef.schemaName === item.schemaName, |
Contributor
Author
There was a problem hiding this comment.
I don't know why this didn't compare schemaName to find existing fields' metadata. When comparing to methodName it wrongly assumes the methodName will always reflect the schemaName, which is not the case.
thiagomini
commented
Jan 2, 2026
| import { GraphQLSchemaBuilder } from '../lib/graphql-schema.builder'; | ||
| import { ResolversExplorerService } from '../lib/services/resolvers-explorer.service'; | ||
| import { ScalarsExplorerService } from '../lib/services/scalars-explorer.service'; | ||
| import gql from 'graphql-tag'; |
Contributor
Author
There was a problem hiding this comment.
This is an unused import
4 tasks
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.
Closes #3778
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Issue Number: #3778
What is the new behavior?
Extensions are correctly applied to resolved fields with renamed method names.
Does this PR introduce a breaking change?
Other information
This bug only occurs when we use a custom method name for a resolve field. If we rename the method mentioned above to
status, it works as expected.However, it's worth noting that the underlying reason for this bug is how the
TypeMetadataStorageclass identifies a GQL field's metadata - when we rename a resolver's method name, it handles it as a new field . The fix I'll propose for this will probably fix #3524 too - but there's a catch here - this might impact how existing applications using the code-first approach build their schemas.Currently, if we define an Object's field's metadata in both the DTO and in the @ResolveField() decorator, the
@ResolveField()will take precedence (but that's a bug, as I mentioned, because of how the metadata storage thinks the method decorated with @ResolveField is actually a new field when renamed). Let's recap the example:Notice the
statusfield description:DTO Description.Now, let's look at the @ResolveField definition:
Right now, when our application schema is generated, the final description will be
Resolve Field Description. But if we fix the existing bug, the field description will be updated toDTO Description.I wanted to mention this because there might be several applications right now that will have their schema definitions changed if there are any discrepancies between the DTO and the @ResolveField, so, Kamil, you probably need to decide whether to apply this patch to a new major version or a hotfix.