Skip to content
Permalink
Browse files

Add Plugin:cache

  • Loading branch information...
shfshanyue committed Jul 31, 2019
1 parent d6973f1 commit e40f59640f472146a4e9f1c94832ca431a0dbb11
Showing with 90 additions and 57 deletions.
  1. +10 −0 index.ts
  2. +78 −57 package-lock.json
  3. +2 −0 package.json
@@ -2,6 +2,8 @@ import { ApolloServer } from 'apollo-server-koa'
import Koa from 'koa'
import bodyParser from 'koa-bodyparser'
import _ from 'lodash'
import responseCachePlugin from 'apollo-server-plugin-response-cache'
import { RedisCache } from 'apollo-server-cache-redis'
import { formatError, Exception, apiLogger, session, redis } from './lib'
import { typeDefs, resolvers } from './src'
import directives from './src/directives'
@@ -39,6 +41,14 @@ const server = new ApolloServer({
duration: _.get(response, 'extensions.tracing.duration', 0) / 1000000
})
},
cacheControl: {
defaultMaxAge: 5
},
cache: new RedisCache({
host: config.redis.host,
password: config.redis.password
}),
plugins: [responseCachePlugin()],
schemaDirectives: directives,
rootValue: {},
playground: true,

0 comments on commit e40f596

Please sign in to comment.
You can’t perform that action at this time.