Debuggin graphql & mercurius
This commit is contained in:
@@ -1,10 +1,21 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { AppController } from './app.controller';
|
||||
import { AppService } from './app.service';
|
||||
import { GraphQLModule } from '@nestjs/graphql';
|
||||
import { MercuriusDriver, MercuriusDriverConfig } from '@nestjs/mercurius';
|
||||
import { HelloResolver } from './hello.resolver';
|
||||
|
||||
@Module({
|
||||
imports: [],
|
||||
imports: [
|
||||
GraphQLModule.forRoot<MercuriusDriverConfig>({
|
||||
driver: MercuriusDriver,
|
||||
path: '/api/graphql',
|
||||
graphiql: true,
|
||||
autoSchemaFile: true
|
||||
} as MercuriusDriverConfig),
|
||||
],
|
||||
controllers: [AppController],
|
||||
providers: [AppService],
|
||||
providers: [AppService,HelloResolver],
|
||||
|
||||
})
|
||||
export class AppModule {}
|
||||
|
||||
10
src/hello.resolver.ts
Normal file
10
src/hello.resolver.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { Resolver, Query } from '@nestjs/graphql';
|
||||
|
||||
@Resolver()
|
||||
export class HelloResolver {
|
||||
|
||||
@Query(() => String)
|
||||
hello(): string {
|
||||
return 'hello world';
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,9 @@
|
||||
import { NestFactory } from '@nestjs/core';
|
||||
import { AppModule } from './app.module';
|
||||
import { NestFastifyApplication, FastifyAdapter } from '@nestjs/platform-fastify';
|
||||
|
||||
async function bootstrap() {
|
||||
const app = await NestFactory.create(AppModule);
|
||||
const app = await NestFactory.create<NestFastifyApplication>(AppModule, new FastifyAdapter());
|
||||
await app.listen(process.env.PORT ?? 3000);
|
||||
}
|
||||
bootstrap();
|
||||
|
||||
Reference in New Issue
Block a user