const SOMETHING_CHANGED_TOPIC = 'something_changed';
export const resolvers = {
Subscription: {
somethingChanged: {
subscribe: () => pubsub.asyncIterator(SOMETHING_CHANGED_TOPIC),
},
},
}
pubsub.publish(SOMETHING_CHANGED_TOPIC, { somethingChanged: { id: "123" }})
See: https://github.com/apollographql/graphql-subscriptions
export const resolvers = {
Subscription: {
todoChanged(_parent, args, info): {
subscribe: () => pubsub.asyncIterator(SOMETHING_CHANGED_TOPIC + "_" + hashFn(args.filter) || ""),
},
},
}
Publish:
pubsub.publish(hashFn(SOMETHING_CHANGED_TOPIC), { somethingChanged: { id: "123" }})
Ideally we need to have both approaches. hashFn is embeeded on compilation time which means we cannot handle this for cases like graphql-serve etc.
We can have generic hash method for investigation. It is to expose some filter arguments.
For common filters this will be very beneficial. Drawback of this option is that we need to be aware of the hashes when publishing
that makes this very hard to horizontally scale.
Please read this graphback documentation chapter: https://graphback.dev/docs/next/authentication/keycloak#dynamic-filtering
We can do anything we want - including pulling context etc.
Yes. Please check datasync starter:
https://github.com/aerogear/datasync-starter/blob/master/server/src/crudServiceCreator.ts#L61
and
https://github.com/aerogear/datasync-starter/blob/master/.openshift/amq-topics.yml#L20-L22
and
https://github.com/aerogear/datasync-starter/blob/master/.openshift/README.md