'use strict' ; import * as bunyan from 'bunyan' ; const log = bunyan . createLogger ( { name : 'sample-graphql' } ) ; import 'babel-polyfill' ; import lambdaPlayground from 'graphql-playground-middleware-lambda' ; import { makeExecutableSchema } from 'graphql-tools' ; import { graphqlLambda } from 'apollo-server-lambda/dist/lambdaApollo' ; import { schema } from './schema' ; import { resolvers } from './resolvers' ; const myGraphQLSchema = makeExecutableSchema ( { typeDefs : schema , resolvers , logger : console } ) ; exports . graphqlHandler = function graphqlHandler ( event , context , callback ) { log . info ( 'hit graphql' ) ; function callbackFilter ( error , output ) { if ( output ) { output . headers [ 'Access-Control-Allow-Origin' ] = '*' ; log . info ( output . body ) ; } else { log . error ( error ) ; } callback ( error , output ) ; } const handler = graphqlLambda ( { schema : myGraphQLSchema , tracing : true } ) ; return handler ( event , context , callbackFilter ) ; } ; exports . playgroundHandler = lambdaPlayground ( { endpoint : process . env . REACT_APP_GRAPHQL_ENDPOINT ? process . env . REACT_APP_GRAPHQL_ENDPOINT : '/production/graphql' } ) ;