File tree Expand file tree Collapse file tree 2 files changed +10
-6
lines changed Expand file tree Collapse file tree 2 files changed +10
-6
lines changed Original file line number Diff line number Diff line change 1818- Improved the test utility ` promisifyEvent ` function.
1919- Test the ` GraphQL.operate() ` option ` reloadOnLoad ` in isolation.
2020- Test better the order of ` GraphQL.operate() ` triggered events.
21+ - Reduced the number of promises created by ` GraphQL.operate() ` when the ` reloadOnLoad ` and ` reloadOnLoad ` options are ` false ` .
2122- Added a code example for how to await all loading GraphQL operations.
2223- Used consistent JSDoc types for promises that resolve ` void ` .
2324
Original file line number Diff line number Diff line change @@ -305,12 +305,15 @@ module.exports = class GraphQL {
305305 const cacheKey = cacheKeyCreator ( fetchOptions ) ;
306306 const cacheValuePromise = this . fetch ( fetchOptions , cacheKey ) ;
307307
308- // Potential edge-case issue: Multiple identical queries with `resetOnLoad`
309- // enabled will cause excessive resets.
310- cacheValuePromise . then ( ( ) => {
311- if ( reloadOnLoad ) this . reload ( cacheKey ) ;
312- else if ( resetOnLoad ) this . reset ( cacheKey ) ;
313- } ) ;
308+ // A reload or reset happens after the cache is updated as a side effect.
309+ if ( reloadOnLoad )
310+ cacheValuePromise . then ( ( ) => {
311+ this . reload ( cacheKey ) ;
312+ } ) ;
313+ else if ( resetOnLoad )
314+ cacheValuePromise . then ( ( ) => {
315+ this . reset ( cacheKey ) ;
316+ } ) ;
314317
315318 return {
316319 cacheKey,
You can’t perform that action at this time.
0 commit comments