Filtering Subscriptions by Event Type #1183
-
| 
         Hello, I have a very noisy event bus that I would like users to be able to subscribe to and only get events that they asked for. Using the example from the documentation, I have a  A user may write a query like this: subscription {
    userEvents {
        __typename
        ... on UserCreated {
            id
            name
        }
    }
}My current understanding is that on  Ideally, I would like the server to filter out events that don't have any requested fields, but I am not sure how to go about this.  | 
  
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
| 
         I don't think you can use  What you could do: 
 Inside the resolve function, you have access to  Another way is to use parameters: but it's a bit redundant.  | 
  
Beta Was this translation helpful? Give feedback.
I don't think you can use
__typenameas this is for introspection.It will always return the type of
idandname, and not the valuesWhat you could do:
userEventsreturns an interface, thatUserCreatedimplements.Inside the resolve function, you have access to
ctx.astFields. With that, you could find the informationUserCreatedand adapt the resolution.Another way is to use parameters:
but it's a bit redundant.