Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save homerquan/b14a55b61f2753b95ebe2a5b3aa29c57 to your computer and use it in GitHub Desktop.
Save homerquan/b14a55b61f2753b95ebe2a5b3aa29c57 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