Class: GraphQLModule
Defined in: packages/apollo/src/graphql.module.ts:61
GraphQL module for nestelia backed by Apollo Server. Provides static and async configuration methods.
Example
typescript
GraphQLModule.forRoot({
path: "/graphql",
autoSchemaFile: true,
playground: true,
})Implements
Constructors
Constructor
ts
new GraphQLModule(): GraphQLModule;Returns
GraphQLModule
Methods
onModuleDestroy()
ts
onModuleDestroy(): void;Defined in: packages/apollo/src/graphql.module.ts:62
Returns
void
Implementation of
OnModuleDestroy.onModuleDestroy
forRoot()
ts
static forRoot(options): DynamicModule;Defined in: packages/apollo/src/graphql.module.ts:91
Configures GraphQL with static options. The Apollo Server is started eagerly during module bootstrap.
Parameters
| Parameter | Type | Description |
|---|---|---|
options | ApolloOptions | GraphQL configuration options. |
Returns
Dynamic module configuration.
Example
typescript
import { ElysiaFactory } from 'nestelia';
const app = await ElysiaFactory.create(AppModule);
@Module({
imports: [
GraphQLModule.forRoot({
path: '/graphql',
autoSchemaFile: true,
playground: true,
})
]
})
class AppModule {}forRootAsync()
ts
static forRootAsync(options): DynamicModule;Defined in: packages/apollo/src/graphql.module.ts:140
Configures GraphQL with async options resolved from the DI container.
Parameters
| Parameter | Type | Description |
|---|---|---|
options | { inject?: ProviderToken[]; useFactory: (...args) => | ApolloOptions<unknown> | Promise<ApolloOptions<unknown>>; } | Async configuration options. |
options.inject? | ProviderToken[] | - |
options.useFactory | (...args) => | ApolloOptions<unknown> | Promise<ApolloOptions<unknown>> | - |
Returns
Dynamic module configuration.
Example
typescript
GraphQLModule.forRootAsync({
useFactory: async (configService: ConfigService) => ({
path: '/graphql',
autoSchemaFile: true,
playground: configService.get('NODE_ENV') !== 'production',
}),
inject: [ConfigService],
})