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

Add client to Query's QueryResult #1488

Merged
merged 7 commits into from
Dec 29, 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
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ first three params (`TChildProps` can be derived). [#1402](https://github.com/ap
- Updates to `examples/typescript` [#1471](https://github.com/apollographql/react-apollo/pull/1471)
- Mutation test cleanup [#1480](https://github.com/apollographql/react-apollo/pull/1480)
- Removed react-native from the test suite [#1451](https://github.com/apollographql/react-apollo/pull/1451)
- Add `client` to `Query`'s `QueryResult` [#1488](https://github.com/apollographql/react-apollo/pull/1488)

### 2.0.4
- rolled back on the lodash-es changes from
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"scripts": {
"danger": "danger run --verbose",
"deploy": "./scripts/prepare-package.sh && cd npm && npm publish",
"test": "npm run lint && npm run type-check && npm run testonly",
"testonly": "jest --maxWorkers=4 --coverage",
"test": "npm run lint && npm run type-check && npm run jest",
"jest": "jest --maxWorkers=4 --coverage",
"test-watch": "jest --watch",
"filesize": "bundlesize",
"type-check": "tsc --project tsconfig.json --noEmit && flow check",
Expand Down
8 changes: 3 additions & 5 deletions src/Query.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ function observableQueryFields(observable) {
}

export interface QueryResult<TData = any> {
client: ApolloClient<any>;
data: TData;
error?: ApolloError;
fetchMore: (
Expand Down Expand Up @@ -176,18 +177,15 @@ class Query<TData = any> extends React.Component<

private getQueryResult = (): QueryResult<TData> => {
const { result } = this.state;

const { loading, error, networkStatus, data } = result;

const renderProps = {
return {
client: this.client,
data,
loading,
error,
networkStatus,
...observableQueryFields(this.queryObservable),
};

return renderProps;
};
}

Expand Down
Loading