Skip to content

Commit

Permalink
Simplify fetchMore cleanup logic.
Browse files Browse the repository at this point in the history
  • Loading branch information
benjamn committed Apr 9, 2019
1 parent 9c57833 commit 6d5078b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
- Avoid updating (and later invalidating) cache watches when `fetchPolicy` is `'no-cache'`. <br/>
[@bradleyayers](https://github.com/bradleyayers) in [PR #4573](https://github.com/apollographql/apollo-client/pull/4573), part of [issue #3452](https://github.com/apollographql/apollo-client/issues/3452)

- Remove temporary `queryId` after `fetchMore` completes. <br/>
[@doomsower](https://github.com/doomsower) in [#4440](https://github.com/apollographql/apollo-client/pull/4440)

### Apollo Cache In-Memory

- Support `new InMemoryCache({ freezeResults: true })` to help enforce immutability. <br/>
Expand Down
9 changes: 6 additions & 3 deletions packages/apollo-client/src/core/ObservableQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -343,12 +343,10 @@ export class ObservableQuery<
);

let combinedOptions: any;
let qid: string;
const qid = this.queryManager.generateQueryId();

return Promise.resolve()
.then(() => {
qid = this.queryManager.generateQueryId();

if (fetchMoreOptions.query) {
// fetch a new query
combinedOptions = fetchMoreOptions;
Expand Down Expand Up @@ -381,9 +379,14 @@ export class ObservableQuery<
variables: combinedOptions.variables,
}),
);

this.queryManager.stopQuery(qid);

return fetchMoreResult as ApolloQueryResult<TData>;

}, error => {
this.queryManager.stopQuery(qid);
throw error;
});
}

Expand Down

0 comments on commit 6d5078b

Please sign in to comment.