diff --git a/package.json b/package.json index b6e61da3e8..5c2b01cd5e 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "peerDependencies": { "react": "0.14.x || 15.* || ^15.0.0", "redux": "^2.0.0 || ^3.0.0", - "apollo-client": "^0.4.21 || ^0.5.1" + "apollo-client": "^0.4.21 || ^0.5.0" }, "devDependencies": { "@types/chai": "^3.4.33", @@ -69,7 +69,7 @@ "@types/redux-form": "^4.0.29", "@types/redux-immutable": "^3.0.30", "@types/sinon": "^1.16.29", - "apollo-client": "^0.4.21", + "apollo-client": "^0.5.0-1", "babel-jest": "^14.1.0", "babel-preset-react-native": "^1.9.0", "browserify": "^13.0.0", diff --git a/src/graphql.tsx b/src/graphql.tsx index 00bfc41b74..0d65e92594 100644 --- a/src/graphql.tsx +++ b/src/graphql.tsx @@ -67,7 +67,7 @@ const defaultMapPropsToSkip = props => false; // the fields we want to copy over to our data prop function observableQueryFields(observable) { const fields = pick(observable, 'variables', - 'refetch', 'fetchMore', 'updateQuery', 'startPolling', 'stopPolling'); + 'refetch', 'fetchMore', 'updateQuery', 'startPolling', 'stopPolling', 'subscribeToMore'); Object.keys(fields).forEach((key) => { if (typeof fields[key] === 'function') { diff --git a/test/react-web/client/graphql/queries-1.test.tsx b/test/react-web/client/graphql/queries-1.test.tsx index 8ad9bd8ea5..12c3e7193a 100644 --- a/test/react-web/client/graphql/queries-1.test.tsx +++ b/test/react-web/client/graphql/queries-1.test.tsx @@ -1079,6 +1079,27 @@ describe('queries', () => { renderer.create(); }); + it('exposes subscribeToMore as part of the props api', (done) => { + const query = gql`query people { allPeople(first: 1) { people { name } } }`; + const data = { allPeople: { people: [ { name: 'Luke Skywalker' } ] } }; + const networkInterface = mockNetworkInterface({ request: { query }, result: { data } }); + const client = new ApolloClient({ networkInterface, addTypename: false }); + + @graphql(query) + class Container extends React.Component { + componentWillReceiveProps({ data }) { // tslint:disable-line + expect(data.subscribeToMore).toBeTruthy(); + expect(data.subscribeToMore instanceof Function).toBe(true); + done(); + } + render() { + return null; + } + }; + + renderer.create(); + }); + it('exposes startPolling as part of the props api', (done) => { const query = gql`query people { allPeople(first: 1) { people { name } } }`; const data = { allPeople: { people: [ { name: 'Luke Skywalker' } ] } };