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

add shouldResubscribe option #389

Merged
merged 2 commits into from
Jan 5, 2017

Conversation

gilesbradshaw
Copy link
Contributor

A should resubscribe option makes subscription queries optionally resubscribe when the props change..

I use it like this:

const NODE_SUBSCRIPTION_QUERY = gql`
  subscription  - blah blah ....

const NODE_QUERY = gql`
  query  - blah blah ....

const _Node = (props) => <Blah />

const options = {
  shouldResubscribe: (props, nextProps) => {
    // if the id property changes then we need to resubscribe..
    return nextProps.id !== props.id
  }
}
const Node = compose(
  graphql(NODE_SUBSCRIPTION_QUERY, options),
  graphql(NODE_QUERY)
)(_Node)

@apollo-cla
Copy link

@gilesbradshaw: Thank you for submitting a pull request! Before we can merge it, you'll need to sign the Meteor Contributor Agreement here: https://contribute.meteor.com/

@jbaxleyiii
Copy link
Contributor

@gilesbradshaw nice! can you add this to the docs site as well?

@jbaxleyiii jbaxleyiii merged commit 92caa83 into apollographql:master Jan 5, 2017
@gilesbradshaw
Copy link
Contributor Author

sure! apollostack/react-docs#138

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants