type Subscription {
# Subscription fires on every message added
# for any of the groups with one of these groupIds
messageAdded(groupIds: [Int]): Message
}
Right now, my withFilter resolver might look like this:
That’s pretty cool, but this means that every subscriber to messageAdded will get a message and then filter for whether to publish to client based on the myFilter function. Not very scalable :/
The most obvious way to fix this to me is to publish more distinct topics:
Now pubsub.publish will publish something like messageAdded.1 for a message added to Group 1, and only users subscribed to messageAdded.1 will receive the message and run it through myFilter. But currently asyncIteratorFn doesn't have access to the args, context, etc to make distinct topic(s) like messageAdded.1
So while this fix is a small bit of code, I think it could make withFilter a much more scalable helper function :)
I think this is might be what I’m looking for.
Let’s say my GQL sub is something like:
Right now, my withFilter resolver might look like this:
That’s pretty cool, but this means that every subscriber to
messageAdded
will get a message and then filter for whether to publish to client based on themyFilter
function. Not very scalable :/The most obvious way to fix this to me is to publish more distinct topics:
Now
pubsub.publish
will publish something likemessageAdded.1
for a message added to Group 1, and only users subscribed tomessageAdded.1
will receive the message and run it throughmyFilter
. But currentlyasyncIteratorFn
doesn't have access to theargs
,context
, etc to make distinct topic(s) likemessageAdded.1
So while this fix is a small bit of code, I think it could make
withFilter
a much more scalable helper function :)