Enforce return value type for GraphQL resolvers in NestJS

Viewed 249

Is there a way to enforce the return value of a @Query function inside resolvers? Given the code below:

@Resolver(() => Project)
export class ProjectResolver {
  constructor(private projectService: ProjectService) {}

  @Query(() => [ProjectFull])
  async projects() {
    // return anything
  }
}

projects method can return anything w/o Typescript complaining. We could annotate the method with a return type (even enforce this annotation using eslint), but it won't be attached to the return type of a query.

0 Answers
Related