@Context decorator undefined for property resolvers
See original GitHub issueI’m submitting a…
[x] Regression
Current behavior
Given the following GraphQL resolver:
@Resolver('SearchResponse')
export class ShopFulltextSearchResolver implements Omit<BaseSearchResolver, 'reindex'> {
constructor(private fulltextSearchService: FulltextSearchService) {}
@Query()
async search(
@Ctx() ctx: RequestContext,
@Args() args: SearchQueryArgs,
): Promise<Omit<SearchResponse, 'facetValues'>> {
return this.fulltextSearchService.search(ctx, args.input);
}
@ResolveProperty()
async facetValues(
@Ctx() ctx: RequestContext,
@Context() context: any,
): Promise<Array<{ facetValue: FacetValue; count: number }>> {
return this.fulltextSearchService.facetValues(ctx, context.req.body.variables.input);
}
}
- the
search
method resolves a top-level query - the
facetValues
method resolves a property of theSearchResponse
type.
The context
variable is undefined
in the facetValues
method.
Expected behavior
The context
variable should contain the GraphQL context object, including the underlying express req
object which I am making use of in the method body.
Note that this worked in Nest v6.0.2. After upgrading today to v6.0.5 it stopped working. Also, the @Context
decorator appears to work as expected for top-level queries. Only property resolvers are broken.
Minimal reproduction of the problem with instructions
I put together this repo, which does not exactly reproduce the behaviour in my app but is close. In this case, the context
object is empty, rather than undefined: https://github.com/michaelbromley/nest-issue-191-repro
Environment
Nest version: 6.0.5, graphql v6.0.4
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:9 (2 by maintainers)
Top Results From Across the Web
Resolvers | NestJS - A progressive Node.js framework
decorator. In this example, we defined a query handler to get the author object based on the id sent in the request. To...
Read more >Writing query resolvers | Full-Stack Quickstart
The resolver function signature ; context, This object is shared across all resolvers that execute for a particular operation. Use this to share...
Read more >applyResolversEnhanceMap not adding custom ...
I'm using the typegraphql-prisma package and am trying to apply custom decorators to my generated resolvers to no avail.
Read more >How to use the @nestjs/graphql.Context function in ...
To help you get started, we've selected a few @nestjs/graphql.Context examples, based on popular ways it is used in public projects.
Read more >type-graphql/Lobby - Gitter
ERROR: TypeError: Cannot read property 'getObjectType' of undefined at ... Error: No provided object type in '@Resolver' decorator for class ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Could you please check with
@nestjs/graphql@6.0.5
? Thanks for reportingThis thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.