Complete the code to import the GraphQL module in a NestJS app.
import { [1] } from '@nestjs/graphql';
The GraphQLModule is the main module to integrate GraphQL in NestJS.
Complete the code to configure GraphQL in NestJS with code-first approach.
GraphQLModule.forRoot({
autoSchemaFile: [1],
}),Setting autoSchemaFile to true enables code-first schema generation.
Fix the error in the resolver decorator to define a GraphQL query.
@[1]() export class SampleResolver { @Query(() => String) hello() { return 'Hello World'; } }
The @Resolver() decorator marks the class as a GraphQL resolver in NestJS.
Fill both blanks to define a GraphQL query method with a return type.
import { Query, [1] } from '@nestjs/graphql'; @Resolver() export class UserResolver { @Query(() => [2]) getUser() { return 'User1'; } }
The Resolver decorator is imported to mark classes, and String is used as the GraphQL return type.
Fill all three blanks to create a GraphQL mutation method with an argument.
import { Mutation, Arg, [1] } from '@nestjs/graphql'; @[2]() export class PostResolver { @Mutation(() => Boolean) createPost(@Arg('[3]') title: string) { return true; } }
The Resolver decorator marks the class, and the argument name title is used in @Arg.
