Skip to content

Instantly share code, notes, and snippets.

@jmn8718
Last active December 21, 2017 16:56
Show Gist options
  • Save jmn8718/89084599c8ba9c550eb3133ef892dc5b to your computer and use it in GitHub Desktop.
Save jmn8718/89084599c8ba9c550eb3133ef892dc5b to your computer and use it in GitHub Desktop.
import { withFilter } from 'graphql-subscriptions';
...
Subscription: {
watchDevice: {
resolve: (payload) => payload,
subscribe: withFilter(
() => pubsub.asyncIterator(deviceConstants.UPDATE_DEVICE),
(payload, args) => payload._id.toString() === args.id,
),
},
watchDevices: {
resolve: (payload) => payload,
subscribe: () => pubsub.asyncIterator([deviceConstants.UPDATE_DEVICE, deviceConstants.CREATE_DEVICE]),
},
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment