import { buildSchema } from 'type-graphql' ; import { singletonAsync } from './singletion' ; export const schema = singletonAsync ( 'graphq-schema' , async ( ) => { const resolvers = [ ] ; const r = require . context ( '../resolvers' , false , /\.resolver\.ts$/ ) ; r . keys ( ) . forEach ( ( key ) => { resolvers . push ( r ( key ) . default ) ; } ) ; const schema = await buildSchema ( { resolvers , } ) ; return schema ; } , process . env . NODE_ENV === 'production' ) ;