Skip to content
This repository has been archived by the owner on Apr 13, 2023. It is now read-only.

Conditionally use AC's ObservableQuery.resetQueryStoreErrors #3151

Merged
merged 2 commits into from
Jun 22, 2019
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
9 changes: 8 additions & 1 deletion Changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
# Change log

## vNext
## 2.5.8 (2019-06-21)

### Bug Fixes

- Makes the use of `apollo-client` 2.6.3's `ObservableQuery.resetQueryStoreErrors`
method optional, for people who can't update to `react-apollo`'s new
`apollo-client` peer dep of 2.6.3. <br/>
[@hwillson](https://github.com/hwillson) in [#3151](https://github.com/apollographql/react-apollo/pull/3151)

## 2.5.7 (2019-06-21)

Expand Down
21 changes: 20 additions & 1 deletion src/Query.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -488,8 +488,27 @@ export default class Query<TData = any, TVariables = OperationVariables> extends
// remove those errors from the `ObservableQuery` query store, so they
// aren't re-displayed on subsequent (potentially error free)
// requests/responses.
//
// NOTE: Resetting query store errors is handled in 2 different ways here,
// since the `resetQueryStoreErrors` wasn't available until
// `apollo-client` 2.6.3. If a previous version of `apollo-client` is
// being used, errors are reset by reaching into `ObservableQuery`'s
// internals. This hack is temporary, as React Apollo 3 will be
// released shortly, and will enforce `apollo-client` 2.6.3 as the
// minimum.
setTimeout(() => {
this.queryObservable!.resetQueryStoreErrors();
if ((this.queryObservable! as any).resetQueryStoreErrors) {
// Apollo Client >= 2.6.3
(this.queryObservable! as any).resetQueryStoreErrors();
} else {
// Apollo Client < 2.6.3
const { queryManager, queryId } = (this.queryObservable! as any);
const queryStore = queryManager.queryStore.get(queryId);
if (queryStore) {
queryStore.networkError = null;
queryStore.graphQLErrors = [];
}
}
});

result.client = this.client;
Expand Down