Skip to content

Commit

Permalink
fix: 🐛 Add return type to @query to fix the schema @tag error
Browse files Browse the repository at this point in the history
  • Loading branch information
zhumeisongsong committed Nov 8, 2024
1 parent 7a730a1 commit aab9433
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
14 changes: 11 additions & 3 deletions apps/users-application/src/users/users.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,18 @@ import { ApolloServerPluginInlineTrace } from '@apollo/server/plugin/inlineTrace
imports: [
GraphQLModule.forRoot<ApolloFederationDriverConfig>({
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 {}
export class UsersModule {}
2 changes: 1 addition & 1 deletion apps/users-application/src/users/users.resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit aab9433

Please sign in to comment.