diff --git a/src/core/ObservableQuery.ts b/src/core/ObservableQuery.ts index 5f79a8ecfba..430b73d91a2 100644 --- a/src/core/ObservableQuery.ts +++ b/src/core/ObservableQuery.ts @@ -326,7 +326,7 @@ export class ObservableQuery< // (no-cache, network-only, or cache-and-network), override it with // network-only to force the refetch for this fetchQuery call. const { fetchPolicy } = this.options; - if (fetchPolicy === 'standby' || fetchPolicy === 'cache-and-network') { + if (fetchPolicy === 'cache-and-network') { reobserveOptions.fetchPolicy = fetchPolicy; } else if (fetchPolicy === 'no-cache') { reobserveOptions.fetchPolicy = 'no-cache'; diff --git a/src/react/hooks/__tests__/useQuery.test.tsx b/src/react/hooks/__tests__/useQuery.test.tsx index 4cb638ed562..acc6060e5e8 100644 --- a/src/react/hooks/__tests__/useQuery.test.tsx +++ b/src/react/hooks/__tests__/useQuery.test.tsx @@ -3029,7 +3029,8 @@ describe('useQuery Hook', () => { expect(result.current.data).toEqual({ hello: 'world' }); }); - it('should not refetch when skip is true', async () => { + // Amusingly, #8270 thinks this is a bug, but #9101 thinks this is not. + it('should refetch when skip is true', async () => { const query = gql`{ hello }`; const link = new ApolloLink(() => Observable.of({ data: { hello: 'world' }, @@ -3056,13 +3057,18 @@ describe('useQuery Hook', () => { expect(result.current.data).toBe(undefined); await expect(waitForNextUpdate({ timeout: 20 })) .rejects.toThrow('Timed out'); - result.current.refetch(); - await expect(waitForNextUpdate({ timeout: 20 })) - .rejects.toThrow('Timed out'); + const promise = result.current.refetch(); + // TODO: Not really sure about who is causing this render. + await waitForNextUpdate(); expect(result.current.loading).toBe(false); expect(result.current.data).toBe(undefined); - expect(requestSpy).toHaveBeenCalledTimes(0); + expect(requestSpy).toHaveBeenCalledTimes(1); requestSpy.mockRestore(); + expect(promise).resolves.toEqual({ + data: {hello: "world"}, + loading: false, + networkStatus: 7, + }); }); });