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

Remove data property from fetchMore result #1416

Merged
merged 3 commits into from
Mar 17, 2017
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
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Expect active development and potentially significant breaking changes in the `0

### vNEXT
- Fix: Update TypeScript Middleware and Afterware interfaces to include a datatype for 'this' in apply function. [PR #1372](https://github.com/apollographql/apollo-client/pull/1372)
- Breaking: Remove data property from fetchMore result [PR #1416](https://github.com/apollographql/apollo-client/pull/1416)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Afaict this changelog item did not make it into https://github.com/apollographql/react-apollo/blob/master/Changelog.md which caused me a great deal of confusion on upgrade.


### 1.0.0-rc.2
- throw error if deprecated options are being used [PR #1396](https://github.com/apollographql/apollo-client/pull/1396)
Expand Down Expand Up @@ -521,4 +522,4 @@ This release has a minor version bump, which means npm will not automatically up

### v0.1.0

Initial release. We didn't track changes before this version.
Initial release. We didn't track changes before this version.
3 changes: 2 additions & 1 deletion src/core/ObservableQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ export class ObservableQuery<T> extends Observable<ApolloQueryResult<T>> {
return this.queryManager.fetchQuery(qid, combinedOptions, FetchType.normal, this.queryId);
})
.then((fetchMoreResult) => {
const { data } = fetchMoreResult;
const reducer = fetchMoreOptions.updateQuery;
const mapFn = (previousResult: any, { variables }: {variables: any }) => {

Expand All @@ -241,7 +242,7 @@ export class ObservableQuery<T> extends Observable<ApolloQueryResult<T>> {
const queryVariables = variables;
return reducer(
previousResult, {
fetchMoreResult,
fetchMoreResult: data,
queryVariables,
});
};
Expand Down
8 changes: 4 additions & 4 deletions test/fetchMore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ describe('fetchMore on an observable query', () => {
variables: { start: 10 }, // rely on the fact that the original variables had limit: 10
updateQuery: (prev, options) => {
const state = cloneDeep(prev) as any;
state.entry.comments = [...state.entry.comments, ...(options.fetchMoreResult as any).data.entry.comments];
state.entry.comments = [...state.entry.comments, ...(options.fetchMoreResult as any).entry.comments];
return state;
},
});
Expand Down Expand Up @@ -273,7 +273,7 @@ describe('fetchMore on an observable query', () => {
variables: variables2,
updateQuery: (prev, options) => {
const state = cloneDeep(prev) as any;
state.entry.comments = [...state.entry.comments, ...(options.fetchMoreResult as any).data.comments];
state.entry.comments = [...state.entry.comments, ...(options.fetchMoreResult as any).comments];
return state;
},
});
Expand Down Expand Up @@ -318,7 +318,7 @@ describe('fetchMore on an observable query', () => {
variables: { start: 10 },
updateQuery: (prev, options) => {
const state = cloneDeep(prev) as any;
state.entry.comments = [...state.entry.comments, ...(options.fetchMoreResult as any).data.entry.comments];
state.entry.comments = [...state.entry.comments, ...(options.fetchMoreResult as any).entry.comments];
return state;
},
});
Expand Down Expand Up @@ -373,7 +373,7 @@ describe('fetchMore on an observable query', () => {
variables: { start: 10 },
updateQuery: (prev, options) => {
const state = cloneDeep(prev) as any;
state.entry.comments = [...state.entry.comments, ...(options.fetchMoreResult as any).data.entry.comments];
state.entry.comments = [...state.entry.comments, ...(options.fetchMoreResult as any).entry.comments];
return state;
},
});
Expand Down