require ( 'dotenv' ) . config ( ) ; import cookieParser from 'cookie-parser' ; import { FilterRootFields , mergeSchemas , RenameTypes , transformSchema , } from 'graphql-tools' ; import { GraphQLServer , Options } from 'graphql-yoga' ; import makeGitHubSchema from './lib/makeGitHubSchema' ; import schema from './schema' ; import { prisma } from './__generated__/prisma-client' ; makeGitHubSchema ( ) . then ( gitHubSchema => { const transformedGitHubSchema = transformSchema ( gitHubSchema , [ new RenameTypes ( name => `GitHub${ name }` ) , new FilterRootFields ( ( _ , fieldName ) => [ 'search' , 'viewer' ] . includes ( fieldName ) ) , ] ) ; const server = new GraphQLServer ( { schema : mergeSchemas ( { schemas : [ schema , transformedGitHubSchema ] } ) , context : params => ( { ... params , prisma } ) , } ) ; server . express . use ( cookieParser ( ) ) ; server . start ( { endpoint : '/graphql' , cors : { credentials : true , origin : 'http://localhost:3000' , } , } , ( { port } ) => { console . log ( `Server running on port ${ port }` ) ; } ) ; } ) ;