mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-12 12:28:42 +00:00
34 lines
853 B
TypeScript
34 lines
853 B
TypeScript
import type { ApolloDriverConfig } from '@nestjs/apollo';
|
|
import { ApolloDriver } from '@nestjs/apollo';
|
|
import { Global, Module } from '@nestjs/common';
|
|
import { GraphQLModule } from '@nestjs/graphql';
|
|
import { join } from 'path';
|
|
import { fileURLToPath } from 'url';
|
|
|
|
import { Config } from './config';
|
|
|
|
@Global()
|
|
@Module({
|
|
imports: [
|
|
GraphQLModule.forRootAsync<ApolloDriverConfig>({
|
|
driver: ApolloDriver,
|
|
useFactory: (config: Config) => {
|
|
return {
|
|
...config.graphql,
|
|
path: `${config.path}/graphql`,
|
|
csrfPrevention: {
|
|
requestHeaders: ['content-type'],
|
|
},
|
|
autoSchemaFile: join(
|
|
fileURLToPath(import.meta.url),
|
|
'..',
|
|
'schema.gql'
|
|
),
|
|
};
|
|
},
|
|
inject: [Config],
|
|
}),
|
|
],
|
|
})
|
|
export class GqlModule {}
|