Skip to content

Commit

Permalink
fix: Fix QuerySubscription reuse (#539)
Browse files Browse the repository at this point in the history
  • Loading branch information
taion authored Jul 24, 2020
1 parent e4df12b commit e6a6d16
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/Resolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ export default class Resolver {
}

const variables = routeVariables[i];
const cacheConfig = cacheConfigs[i];
const fetchPolicy = fetchPolicies[i];

const lastQuerySubscription = this.lastQuerySubscriptions[i];

// Match the logic in <QueryRenderer> for not refetching.
Expand All @@ -136,15 +139,19 @@ export default class Resolver {
isEqual(lastQuerySubscription.variables, variables)
) {
this.lastQuerySubscriptions[i] = null;

lastQuerySubscription.cacheConfig = cacheConfig;
lastQuerySubscription.fetchPolicy = fetchPolicy;

return lastQuerySubscription;
}

return new QuerySubscription({
environment: this.environment,
query,
variables,
cacheConfig: cacheConfigs[i],
fetchPolicy: fetchPolicies[i],
cacheConfig,
fetchPolicy,
});
});

Expand Down

0 comments on commit e6a6d16

Please sign in to comment.