import { ApolloServer } from "apollo-server-micro" ; import { Config , Server } from "./types" ; import { buildSchema } from "./schema" ; export async function buildServer ( config ) { const schema = await buildSchema ( config ) ; const server = new ApolloServer ( { schema , logger : config . logger , context : async ( { req , res } ) => { const context = { req , res } ; if ( config . session ) { Object . assign ( context , { session : await config . session ( { req } ) } ) ; } return context ; } , stopOnTerminationSignals : true , introspection : process . env . NODE_ENV === "development" , } ) ; await server . start ( ) ; server . schema = schema ; return server ; }