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

Commit

Permalink
Merge pull request #280 from apollostack/subscribeToMore
Browse files Browse the repository at this point in the history
Add subscribeToMore to passthrough methods
  • Loading branch information
Sashko Stubailo authored Oct 18, 2016
2 parents d3d792b + 57e9a77 commit d43f324
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion src/graphql.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand Down
21 changes: 21 additions & 0 deletions test/react-web/client/graphql/queries-1.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1079,6 +1079,27 @@ describe('queries', () => {
renderer.create(<ProviderMock client={client}><Container /></ProviderMock>);
});

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<any, any> {
componentWillReceiveProps({ data }) { // tslint:disable-line
expect(data.subscribeToMore).toBeTruthy();
expect(data.subscribeToMore instanceof Function).toBe(true);
done();
}
render() {
return null;
}
};

renderer.create(<ProviderMock client={client}><Container /></ProviderMock>);
});

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' } ] } };
Expand Down

0 comments on commit d43f324

Please sign in to comment.