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

Commit

Permalink
Support 2.0 (#980)
Browse files Browse the repository at this point in the history
* Fix issue from broken deploy

* suppor the 2.0 by checking initStore existence
  • Loading branch information
James Baxley authored Aug 13, 2017
1 parent 93ba6ee commit 5b0ec98
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 4 deletions.
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Change log

### vNext
- Feature: Support apollo-client 2.0
- Fix: Scope query recyclers by client [#876](https://github.com/apollographql/react-apollo/pull/876)
- MockNetworkInterface match mock requests regardless of variable order [#973](https://github.com/apollographql/react-apollo/pull/973)

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-apollo",
"version": "1.4.12",
"version": "1.4.13",
"description": "React data container for Apollo Client",
"main": "lib/react-apollo.umd.js",
"module": "./lib/index.js",
Expand Down Expand Up @@ -142,7 +142,7 @@
"uglify-js": "3.0.27"
},
"dependencies": {
"apollo-client": "^1.4.0",
"apollo-client": "^1.4.0 || ^2.0.0-0",
"graphql-anywhere": "^3.0.0",
"graphql-tag": "^2.0.0",
"hoist-non-react-statics": "^2.2.0",
Expand Down
8 changes: 6 additions & 2 deletions src/ApolloProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,17 @@ export default class ApolloProvider extends Component<ProviderProps, any> {
'sure you pass in your client via the "client" prop.',
);

if (!props.store) {
if (!props.store && typeof props.client.initStore === 'function') {
props.client.initStore();
}
}

componentWillReceiveProps(nextProps) {
if (nextProps.client !== this.props.client && !nextProps.store) {
if (
nextProps.client !== this.props.client &&
!nextProps.store &&
typeof nextProps.client.initStore === 'function'
) {
nextProps.client.initStore();
}
}
Expand Down
10 changes: 10 additions & 0 deletions test/react-web/client/ApolloProvider.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,16 @@ describe('<ApolloProvider /> Component', () => {
expect(wrapper.contains(<div className="unique" />)).toBe(true);
});

it('should support the 2.0', () => {
const wrapper = shallow(
<ApolloProvider client={{}}>
<div className="unique" />
</ApolloProvider>,
);

expect(wrapper.contains(<div className="unique" />)).toBe(true);
});

it('should require a client', () => {
const originalConsoleError = console.error;
console.error = () => {
Expand Down

0 comments on commit 5b0ec98

Please sign in to comment.