Created
November 28, 2018 03:44
-
-
Save OutThisLife/354f9f988904650f983656e177b4ee4e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { ApolloServer } from 'apollo-server-express' | |
import * as express from 'express' | |
import { IResolvers } from 'graphql-tools' | |
import * as LRU from 'lru-cache' | |
import typeDefs, { Context } from './types' | |
const router = express.Router() | |
const resolvers: IResolvers<{}, Context> = { | |
JSON: require('graphql-type-json'), | |
Date: require('graphql-iso-date').GraphQLDateTime, | |
Query: {}, | |
Mutation: {} | |
} | |
module.exports = ({ | |
app, | |
cache, | |
dev = false | |
}: { | |
app: express.Express | |
cache: LRU.Cache<any, any> | |
dev?: boolean | |
}) => { | |
new ApolloServer({ | |
typeDefs, | |
resolvers, | |
context: { cache }, | |
introspection: dev, | |
playground: dev, | |
tracing: dev, | |
cacheControl: true | |
}).applyMiddleware({ app }) | |
return router | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment