Debuggin graphql & mercurius

This commit is contained in:
2026-01-29 15:32:07 +01:00
parent 1340ae2d0f
commit b9b64f3572
5 changed files with 3073 additions and 604 deletions

View File

@@ -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
View File

@@ -0,0 +1,10 @@
import { Resolver, Query } from '@nestjs/graphql';
@Resolver()
export class HelloResolver {
@Query(() => String)
hello(): string {
return 'hello world';
}
}

View File

@@ -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();