Graphql: @Resolver+@ResolveProperty doesn't work for method

Created on 9 Sep 2019  路  4Comments  路  Source: nestjs/graphql

@kamilmysliwiec, @MichalLytek I think this issue is similar to #368

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

Decorators @Resolver+@ResolveProperty don't work together on single method.

[Nest] 19238   - 09/09/2019, 6:45:53 PM   [NestFactory] Starting Nest application...
[Nest] 19238   - 09/09/2019, 6:45:53 PM   [InstanceLoader] ApplicationModule dependencies initialized +39ms
[Nest] 19238   - 09/09/2019, 6:45:53 PM   [InstanceLoader] RecipesModule dependencies initialized +1ms
[Nest] 19238   - 09/09/2019, 6:45:53 PM   [InstanceLoader] GraphQLModule dependencies initialized +1ms
(node:19238) UnhandledPromiseRejectionWarning: Error: Book.Book defined in resolvers, but not in schema
(node:19238) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:19238) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Expected behavior


I expect to application at the example will start.

Minimal reproduction of the problem with instructions

https://github.com/galkin/nest-graphql-bug-report/blob/master/src/recipes/recipes.resolver.ts#L49

What is the motivation / use case for changing the behavior?

Environment


Nest version: 6.6.7

For Tooling issues:
- Node version: v10.16.3  
- Platform:  Mac 

Most helpful comment

I want to have several different types at one class

Tracked by: https://github.com/MichalLytek/type-graphql/issues/193

Not possible by now 馃槥

All 4 comments

Shouldn't @Resolver(of => Book) be placed above RecipesResolver class? 馃槙

@MichalLytek, I want to have several different types at one class. For example:

  @Resolver(of => Book)
  @ResolveProperty('recipes', () => [Recipe])
  async recipesAtBook(@Root() book: Book): Promise<Recipe[]> {
    return this.recipesService.findAll({ skip: 0, take: book.pageCount });
  }

 @Resolver(of => Post)
  @ResolveProperty('recipe', () => Recipe)
  async recipesAtBook(@Root() post: post): Promise<Recipe> {
    return this.recipesService.findAll({ skip: 0, take: post.recipeCount });
  }

If it is blocked on type-graphql, then I can remake example with bug report.

I want to have several different types at one class

Tracked by: https://github.com/MichalLytek/type-graphql/issues/193

Not possible by now 馃槥

This 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.

Was this page helpful?
0 / 5 - 0 ratings