import * as fs from 'fs' ; import * as schemaAstPlugin from '@graphql-codegen/schema-ast' ; import { parse , printSchema } from 'graphql' ; import { Types } from '@graphql-codegen/plugin-helpers' ; import { codegen } from '@graphql-codegen/core' ; import path from 'path' ; import schema from '@src/graphql/schema/schema' ; import prismaContext from '@src/lib/prisma/prismaContext' ; async function performCodegen ( options ) { const output = await codegen ( options ) ; fs . writeFile ( path . join ( __dirname , '/graphql/generated/' , options . filename ) , output , ( ) => { console . log ( 'Outputs generated!' ) ; } ) ; } export async function performAstCodegen ( ) { const options = { config : { numericEnums : true , contextType : prismaContext , useIndexSignature : true , } , documents : [ ] , filename : 'schema.graphql' , schema : parse ( printSchema ( schema ) ) , plugins : [ { 'schema-ast' : { } } ] , pluginMap : { 'schema-ast' : schemaAstPlugin , } , } ; performCodegen ( options ) ; }