Resolver doesn't resolve custom ObjectType names
See original GitHub issueI’m submitting a…
[ ] Regression
[x] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.
Current behavior
If you rename an ObjectType via the decorator the resolver (@Resolver
) of nestjs can’t resolve the correct schema. The generated gql schema is fine though.
Expected behavior
The @Resolver
from @nestjs/graphql
resolves custom names like the @Resolver
from type-graphql
Minimal reproduction of the problem with instructions
https://github.com/xXKeyleXx/graphql-minimal-resolver-object-type
Resolver
import { ResolveProperty, Resolver, Root } from '@nestjs/graphql';
@Resolver(of => QuestionSchema)
export class QuestionResolver {
constructor(
private questionService: QuestionService,
) {
}
@ResolveProperty()
async property(@Root() root: any): Promise<QuestionPropertySchema> {
...
}
}
Typescript Schema
import { Field, ID, ObjectType } from 'type-graphql';
@ObjectType('Question')
export class QuestionSchema {
@Field(type => ID)
id: string;
}
Generated Schema
type Question {
id: ID!
}
What is the motivation / use case for changing the behavior?
I would like to have different names in the schema and the actual class because I want the classname to correspond to the file(name) structure we chose.
Environment
+
@nestjs/common: 6.2.3,
@nestjs/core: 6.2.3,
@nestjs/graphql: 6.2.1,
apollo-server-express: 2.5.0
type-graphql: 0.17.4
graphql: 14.3.0
For Tooling issues:
- Node version: v10.15.3
- Platform: Linux (Docker)
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:10 (3 by maintainers)
Top Results From Across the Web
cannot resolve custom object graphql schema - Stack Overflow
I'm trying to set up my schema for Apollo Server, and I'm running into an error. I'm not really sure how to put...
Read more >Resolvers - Apollo GraphQL Docs
A resolver is a function that's responsible for populating the data for a single ... this example doesn't define resolvers for User fields...
Read more >Resolvers - graphql-compose
For simplifying this process you may use ObjectTypeComposer.wrapResolverAs() method. Let take AuthorTC s findMany resolver and create a new one with name ......
Read more >Resolvers - Hot Chocolate v10 - ChilliCream GraphQL Platform
This is documentation for v10, which is no longer actively maintained. ... public string GetGreetings(ObjectType type) => type.Name; ...
Read more >GraphQL API style guide - GitLab Docs
The presenter is initialized using the object resolved by a field, ... having the resolver return the first of a collection if no...
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
Using
@Resolver()
directly fromtype-graphql
will cause side-effects. This issue is about something else that we have to fix on our sideFixed in 6.2.4