31 lines
806 B
TypeScript
31 lines
806 B
TypeScript
import fs from 'fs';
|
|
import path from 'path';
|
|
import { NestFactory } from '@nestjs/core';
|
|
import {
|
|
FastifyAdapter,
|
|
NestFastifyApplication,
|
|
} from '@nestjs/platform-fastify';
|
|
import {
|
|
GraphQLSchemaBuilderModule,
|
|
GraphQLSchemaFactory,
|
|
} from '@nestjs/graphql';
|
|
import { printSchema } from 'graphql';
|
|
import { ItemsResolver } from '../src/items/items.resolver';
|
|
|
|
async function generateSchema() {
|
|
const app = await NestFactory.create<NestFastifyApplication>(
|
|
GraphQLSchemaBuilderModule,
|
|
new FastifyAdapter(),
|
|
);
|
|
await app.init();
|
|
|
|
const gqlSchemaFactory = app.get(GraphQLSchemaFactory);
|
|
const schema = await gqlSchemaFactory.create([ItemsResolver]);
|
|
fs.writeFileSync(
|
|
path.join(path.dirname(__dirname), 'dist', 'schema.gql'),
|
|
printSchema(schema),
|
|
);
|
|
}
|
|
|
|
generateSchema();
|