import {
ApolloServerPluginLandingPageLocalDefault,
} from "@apollo/server/plugin/landingPage/default";
import { ApolloDriver, type ApolloDriverConfig } from "@nestjs/apollo";
import { Module } from "@nestjs/common";
import { ConfigModule } from "@nestjs/config";
import { GraphQLModule } from "@nestjs/graphql";
import { HelloModule } from ".source/module/hello.module";
@Module({
imports: [
ConfigModule.forRoot({
isGlobal: true,
ignoreEnvFile: false,
envFilePath: ["../../.env"],
}),
GraphQLModule.forRoot<ApolloDriverConfig>({
driver: ApolloDriver,
sortSchema: true,
playground: false,
autoSchemaFile: true,
plugins:[ApolloServerPluginLandingPageLocalDefault()],
subscriptions: {
"graphql-ws": true,
},
}),
HelloModule,
],
providers: [],
})
export class AModule {}
#Nest can't resolve dependencies
4 messages · Page 1 of 1 (latest)
import { Module } from "@nestjs/common";
import { HelloResolver } from ".source/resolver/hello.resolver";
import { HelloService } from ".source/service/hello.service";
@Module({
providers: [HelloResolver, HelloService],
})
export class HelloModule {}
import { Query, Resolver } from "@nestjs/graphql";
import type { HelloService } from ".source/service/hello.service";
@Resolver()
export class HelloResolver {
constructor(private readonly helloService: HelloService) {}
@Query(() => String)
public async hello(): Promise<string> {
return this.helloService.hello();
}
}
import { Injectable } from "@nestjs/common";
@Injectable()
export class HelloService {
public async hello(): Promise<string> {
return "World";
}
}