question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Resolver doesn't resolve custom ObjectType names

See original GitHub issue

I’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:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
kamilmysliwieccommented, Jun 5, 2019

Using @Resolver() directly from type-graphql will cause side-effects. This issue is about something else that we have to fix on our side

1reaction
kamilmysliwieccommented, Jun 6, 2019

Fixed in 6.2.4

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found