Skip to content

Commit

Permalink
fix(CacheMiddleware): cached forced requests (thanks @NappyPirate)
Browse files Browse the repository at this point in the history
* Added a flag to the cache middleware to configure the caching of forced requests

* Updated readme to include the new cacheForcedRequests flag

* Always cached forced requests by default

* Made sure to define queryId and variables
  • Loading branch information
NappyPirate authored and nodkz committed Mar 27, 2018
1 parent 0d12b4b commit ad304b8
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/middlewares/cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,12 @@ export default function queryMiddleware(opts?: CacheMiddlewareOpts): Middleware
}

if (req.cacheConfig && req.cacheConfig.force) {
return next(req);
const queryId = req.getID();
const variables = req.getVariables();
const res = await next(req);

cache.set(queryId, variables, res);
return res;
}

try {
Expand Down

0 comments on commit ad304b8

Please sign in to comment.