Skip to content

Instantly share code, notes, and snippets.

@gc-codesnippets
Created August 25, 2017 15:44
Show Gist options
  • Select an option

  • Save gc-codesnippets/9dc9f0d178a18b82ed6b7d9e95ca1756 to your computer and use it in GitHub Desktop.

Select an option

Save gc-codesnippets/9dc9f0d178a18b82ed6b7d9e95ca1756 to your computer and use it in GitHub Desktop.
// subscribe to `CREATED`, `UPDATED` and `DELETED` mutations
this.newMessageObserver = this.props.client.subscribe({
query: gql`
subscription {
Message {
mutation # contains `CREATED`, `UPDATED` or `DELETED`
node {
text
sentBy {
name
}
}
}
}
`,
}).subscribe({
next(data) {
console.log('A mutation of the following type happened on the Message type: ', data.Message.mutation)
console.log('The changed data looks as follows: ', data.Message.node)
},
error(error) {
console.error('Subscription callback with error: ', error)
},
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment