Skip to content

Commit

Permalink
fix partial data being saved when returnPartialData is false
Browse files Browse the repository at this point in the history
  • Loading branch information
brainkim committed Feb 1, 2022
1 parent 659dec7 commit 108d652
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/core/ObservableQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,9 +285,11 @@ export class ObservableQuery<
variablesMustMatch?: boolean,
) {
const last = this.last;
if (last &&
last[key] &&
(!variablesMustMatch || equal(last!.variables, this.variables))) {
if (
last &&
last[key] &&
(!variablesMustMatch || equal(last.variables, this.variables))
) {
return last[key];
}
}
Expand Down Expand Up @@ -761,8 +763,12 @@ once, rather than every time you call fetchMore.`);
result: ApolloQueryResult<TData>,
variables: TVariables | undefined,
) {
if (this.getLastError() || this.isDifferentFromLastResult(result)) {
this.updateLastResult(result, variables);
const lastError = this.getLastError();
if (lastError || this.isDifferentFromLastResult(result)) {
if (lastError || !result.partial || this.options.returnPartialData) {
this.updateLastResult(result, variables);
}

iterateObserversSafely(this.observers, 'next', result);
}
}
Expand Down

0 comments on commit 108d652

Please sign in to comment.