Created
August 25, 2017 15:44
-
-
Save gc-codesnippets/9dc9f0d178a18b82ed6b7d9e95ca1756 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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