diff --git a/src/core/ObservableQuery.ts b/src/core/ObservableQuery.ts index 03ce1732858..b0ab23af1b0 100644 --- a/src/core/ObservableQuery.ts +++ b/src/core/ObservableQuery.ts @@ -183,7 +183,8 @@ export class ObservableQuery< } public getCurrentResult(saveAsLastResult = true): ApolloQueryResult { - const lastResult = this.getLastResult(); + // Use the last result as long as the variables match this.variables. + const lastResult = this.getLastResult(true); const networkStatus = this.queryInfo.networkStatus || diff --git a/src/core/__tests__/ObservableQuery.ts b/src/core/__tests__/ObservableQuery.ts index d3df4d89abe..94bea64470a 100644 --- a/src/core/__tests__/ObservableQuery.ts +++ b/src/core/__tests__/ObservableQuery.ts @@ -798,7 +798,7 @@ describe('ObservableQuery', () => { expect(result.errors).toEqual([error]); expect(observable.getCurrentResult().errors).toEqual([error]); observable.setVariables(differentVariables); - expect(observable.getCurrentResult().errors).toEqual([error]); + expect(observable.getCurrentResult().errors).toBeUndefined(); } else if (handleCount === 2) { expect(result.data).toEqual(dataTwo); expect(observable.getCurrentResult().data).toEqual(