Skip to content

Commit

Permalink
Add Plugin:cache
Browse files Browse the repository at this point in the history
  • Loading branch information
shfshanyue committed Jul 31, 2019
1 parent d6973f1 commit e40f596
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 57 deletions.
10 changes: 10 additions & 0 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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,
Expand Down
Loading

0 comments on commit e40f596

Please sign in to comment.