Skip to content

Commit

Permalink
feat: cache middleware now respects cacheConfig.force flag (thanks @…
Browse files Browse the repository at this point in the history
…voxmatt)

The cacheConfig object (which is optional) can provide a flag to force refetches when a caching middleware is in place.

The config is used on QueryRenderers:
https://github.com/facebook/relay/blob/master/packages/react-relay/modern/ReactRelayQueryRenderer.js#L54

And in the options for a refetch inside a refetch container:
https://facebook.github.io/relay/docs/en/refetch-container.html#refetch
  • Loading branch information
voxmatt authored and nodkz committed Feb 28, 2018
1 parent 334f2b8 commit f8676e8
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/middlewares/cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ export default function queryMiddleware(opts?: CacheMiddlewareOpts): Middleware
if (req.isFormData() && !allowFormData) {
return next(req);
}

if (req.cacheConfig && req.cacheConfig.force) {
return next(req);
}

try {
const queryId = req.getID();
Expand Down

0 comments on commit f8676e8

Please sign in to comment.