import { ApolloServerPluginCacheControl , ApolloServerPluginLandingPageGraphQLPlayground , ApolloServerPluginLandingPageDisabled , } from 'apollo-server-core' ; import { ApolloServer } from 'apollo-server-micro' ; import type { NextApiRequest , NextApiResponse } from 'next' ; import { createContext } from '../../graphql/context' ; import { schema } from '../../graphql/schema' ; export const GRAPHQL_PATH = '/api/graphql' ; export const config = { api : { bodyParser : false , } , } ; export const server = new ApolloServer ( { schema , introspection : true , context : createContext , plugins : [ process . env . NODE_ENV === 'production' ? ApolloServerPluginLandingPageDisabled ( ) : ApolloServerPluginLandingPageGraphQLPlayground ( ) , ApolloServerPluginCacheControl ( { calculateHttpHeaders : false , } ) , ] , } ) ; const serverStart = server . start ( ) ; export default async function handler ( req , res ) { await serverStart ; return server . createHandler ( { path : GRAPHQL_PATH } ) ( req , res ) ; }