How to use apollo-server-redis - 1 common examples

To help you get started, we’ve selected a few apollo-server-redis examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Brikl / serverless-apollo-datasource-redis / handler.js View on Github external
const server = new ApolloServer({
  typeDefs,
  resolvers,
  tracing: true,
  cacheControl: {
    defaultMaxAge: 5,
    stripFormattedExtensions: false,
    calculateCacheControlHeaders: false,
  },
  dataSources: () => {
    return {
      nytimesAPI: new NYTIMESAPI(),
    };
  },  
  cache: new RedisCache({
    connectTimeout: 5000,
    reconnectOnError: function (err) {
      console.log('Reconnect on error', err)
      var targetError = 'READONLY'
      if (err.message.slice(0, targetError.length) === targetError) {
        // Only reconnect when the error starts with "READONLY"
        return true
      }
    },
    retryStrategy: function (times) {
      console.log('Redis Retry', times)
      if (times >= 3) {
        return undefined
      }
      var delay = Math.min(times * 50, 2000)
      return delay

apollo-server-redis

[![npm version](https://badge.fury.io/js/apollo-server-redis.svg)](https://badge.fury.io/js/apollo-server-redis) [![Build Status](https://circleci.com/gh/apollographql/apollo-server.svg?style=svg)](https://circleci.com/gh/apollographql/apollo-server)

MIT
Latest version published 6 years ago

Package Health Score

63 / 100
Full package analysis

Popular apollo-server-redis functions