From aab9433eb3f78fbd5844b086ebe41b465067e079 Mon Sep 17 00:00:00 2001 From: zhumeisongsong Date: Fri, 8 Nov 2024 12:24:39 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20Add=20return=20type=20to?= =?UTF-8?q?=20@query=20to=20fix=20the=20schema=20@tag=20error?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/users-application/src/users/users.module.ts | 14 +++++++++++--- apps/users-application/src/users/users.resolver.ts | 2 +- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/apps/users-application/src/users/users.module.ts b/apps/users-application/src/users/users.module.ts index 446194d..6e48de3 100644 --- a/apps/users-application/src/users/users.module.ts +++ b/apps/users-application/src/users/users.module.ts @@ -13,10 +13,18 @@ import { ApolloServerPluginInlineTrace } from '@apollo/server/plugin/inlineTrace imports: [ GraphQLModule.forRoot({ driver: ApolloFederationDriver, - // autoSchemaFile: true, - + autoSchemaFile: { + /** + * MEMO: + * Because of this problem, so mush need specify the version + * https://github.com/nestjs/graphql/issues/2646#issuecomment-1567381944 + */ + federation: 2, + }, + playground: process.env['NODE_ENV'] !== 'production', + sortSchema: true, plugins: [ApolloServerPluginInlineTrace()], }), ], }) -export class UsersModule {} \ No newline at end of file +export class UsersModule {} diff --git a/apps/users-application/src/users/users.resolver.ts b/apps/users-application/src/users/users.resolver.ts index 04d7704..27c438d 100644 --- a/apps/users-application/src/users/users.resolver.ts +++ b/apps/users-application/src/users/users.resolver.ts @@ -7,7 +7,7 @@ import { UsersService } from './users.service'; export class UsersResolver { constructor(private usersService: UsersService) {} - @Query() + @Query(() => User, { nullable: true }) getUser(@Args({ name: 'id', type: () => ID }) id: number): User | undefined { return this.usersService.findById(id); }