28
loading...
This website collects cookies to deliver better user experience
As a manager and a logged in user,
As an associate and a logged in user,
A resolver name should match the subscription name like newRequestAdded here. In that object, we will have a subscribe object where you define the logic for what data should be returned.
I am using withFilter method that assists me to filter out data that needs to be returned. This is optional.
First parameter that withFilter accepts is the function that you would use to register an event. Subscriptions here work on the concept of PubSub or Publish-Subscribe i.e. you define an event and register it.
How we got this pubsub instance here, I will cover that in the points below. Just the thing to consider is that each subscription has the same pubsub instance throughout the app and each subscription resolver must return an asyncIterator with the array of event names to register those events and get in the pubsub ecosystem.
Second parameter is filter functions that returns true if the criteria is met and subscription should be sent to a client. This function can be async as per your requirements. In this function, you will get