Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add fetchMoreForQueryId safeguards #3469

Merged
merged 5 commits into from
May 25, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions packages/apollo-client/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@
(Android), by instead setting the `prototype` of `this` manually.
[Issue #3236](https://github.com/apollographql/apollo-client/issues/3236)
[PR #3306](https://github.com/apollographql/apollo-client/pull/3306)
- Added safeguards to make sure `QueryStore.initQuery` and
- Added safeguards to make sure `QueryStore.initQuery` and
`QueryStore.markQueryResult` don't try to set the network status of a
`fetchMoreForQueryId` query, if it does not exist in the store.
`fetchMoreForQueryId` query, if it does not exist in the store. This was
happening when a query component was unmounted while a `fetchMore` was still
in flight.
[Issue #3345](https://github.com/apollographql/apollo-client/issues/3345)
[Issue #3466](https://github.com/apollographql/apollo-client/issues/3466)
[PR #3367](https://github.com/apollographql/apollo-client/pull/3367)
[PR #3469](https://github.com/apollographql/apollo-client/pull/3469)

### 2.3.0
- fixed edge case bug of changing fetchPolicies right after resetStore with no variables present
Expand Down
21 changes: 21 additions & 0 deletions packages/apollo-client/src/data/__tests__/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,25 @@ describe('QueryStore', () => {
},
);
});

describe('markQueryError', () => {
it(
'should set the network status of a `fetchMoreForQueryId` query to ' +
'`ready` in the store, if it exists',
() => {
queryStore.markQueryError(queryId, null, queryId);
expect(queryStore.get(queryId).networkStatus).toBe(NetworkStatus.ready);
},
);

it(
'should not attempt to set the network status of a ' +
'`fetchMoreForQueryId` query, if it does not exist in the store',
() => {
expect(() => {
queryStore.markQueryError(queryId, null, 'id-does-not-exist');
}).not.toThrow("Cannot set property 'networkStatus' of undefined");
},
);
});
});