Skip to content

rbilabs/apollo-server-cache-dynamodb

Repository files navigation

apollo-server-cache-dynamodb

CircleCI

This package exports an implementation of KeyValueCache that allows using AWS DynamoDB as a backing store for resource caching in Data Sources.

Usage

const DynamoDB = require('aws-sdk/clients/dynamodb');
const DynamoDBCache = require('apollo-server-cache-dynamodb');

const client = new DynamoDB.DocumentClient();
const cacheOpts = {
  tableName: 'KeyValueCache', // default, table name
  partitionKeyName: 'CacheKey', //default, partition key, must be type S
  valueAttribute: 'CacheValue', //default, value attribute, must be type S
  ttlAttribute: 'CacheTTL', //default, ttl attribute, must be type N
};

const server = new ApolloServer({
  typeDefs,
  resolvers,
  cache: new DynamoDBCache(client, cacheOpts),
  dataSources: () => ({
    moviesAPI: new MoviesAPI(),
  }),
});

About

DynamoDB implementation of KeyValueCache for apollo-server-caching

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 100.0%