Skip to content

Commit

Permalink
fix activeQueries regression
Browse files Browse the repository at this point in the history
  • Loading branch information
mattkrick committed Nov 20, 2016
1 parent f496369 commit 83e752a
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/Cashay.js
Original file line number Diff line number Diff line change
Expand Up @@ -511,14 +511,18 @@ class Cashay {
const {variables = {}} = options;

const sameOps = isObject(options.ops) ? shallowEqual(options.ops, cachedMutation.activeQueries) : true;

// if the affected ops need to be updated or initialized, do so
if (!sameOps || Object.keys(cachedMutation.activeQueries).length === 0) {
cachedMutation.activeQueries = new ActiveQueries(mutationName, options.ops, this.cachedQueries, this.mutationHandlers);
}

if (cachedMutation.fullMutation) {
if (sameOps && hasMatchingVariables(variables, cachedMutation.variableSet)) return;
if (hasMatchingVariables(variables, cachedMutation.variableSet)) return;
// variable definitions and args will change, nuke the cached mutation + single ASTs
cachedMutation.clear(true);
}
if (!cachedMutation.activeQueries || !sameOps) {
cachedMutation.activeQueries = new ActiveQueries(mutationName, options.ops, this.cachedQueries, this.mutationHandlers);
}

this._createMutationsFromQueries(mutationName, cachedMutation.activeQueries, variables);
}

Expand Down

0 comments on commit 83e752a

Please sign in to comment.