Skip to content

Commit

Permalink
feat(rest-datasource): add apollo-server-cache-redis-cluster package
Browse files Browse the repository at this point in the history
  • Loading branch information
eberhara committed Oct 7, 2018
1 parent 0ebf890 commit 1dc5c14
Show file tree
Hide file tree
Showing 13 changed files with 1,279 additions and 1,110 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

- Allow an optional function to resolve the `rootValue`, passing the `DocumentNode` AST to determine the value. [PR #1555](https://github.com/apollographql/apollo-server/pull/1555)
- Follow-up on the work in [PR #1516](https://github.com/apollographql/apollo-server/pull/1516) to also fix missing insertion cursor/caret when a custom GraphQL configuration is specified which doesn't specify its own `cursorShape` property. [PR #1607](https://github.com/apollographql/apollo-server/pull/1607)
- Add `apollo-server-cache-redis-cluster` package to support Redis Cluster and Sentinels. [PR #1770](https://github.com/apollographql/apollo-server/pull/1770)


### v2.1.0

Expand Down
28 changes: 28 additions & 0 deletions __mocks__/ioredis.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
const IORedis = jest.genMockFromModule('ioredis');

const keyValue = {};

const getKey = key => {
if (keyValue[key]) {
return Promise.resolve(keyValue[key].value);
}

return Promise.resolve(undefined);
};

const mGetKey = (key, cb) => getKey(key).then((val) => [val]);

const setKey = (key, value, type, ttl) => {
keyValue[key] = {
value,
ttl
}
setTimeout(() => { delete keyValue[key] }, ttl * 1000);
return Promise.resolve(true);
};

IORedis.prototype.get.mockImplementation(getKey);
IORedis.prototype.mget.mockImplementation(mGetKey);
IORedis.prototype.set.mockImplementation(setKey);

export default IORedis;
Loading

0 comments on commit 1dc5c14

Please sign in to comment.