Introduction
Subscription filtering helps you get only the updates you care about in real time. It saves data and keeps your app fast.
Subscription filtering helps you get only the updates you care about in real time. It saves data and keeps your app fast.
subscription SubscriptionName($filter: FilterType) {
eventName(filter: $filter) {
field1
field2
}
}subscription OnNewMessage($roomId: ID!) {
messageAdded(filter: {roomId: $roomId}) {
id
content
sender
}
}subscription OnPriceChange($productId: ID!) {
priceUpdated(filter: {productId: $productId}) {
productId
newPrice
}
}This subscription listens for status changes of a specific user only.
subscription OnUserStatusChange($userId: ID!) {
userStatusChanged(filter: {userId: $userId}) {
userId
status
}
}Filters help reduce unnecessary data and improve app performance.
Make sure your backend supports filtering in subscriptions.
Subscription filtering sends only relevant real-time updates.
Use filters to specify which events you want to receive.
This keeps your app efficient and user-friendly.
newMessages that filters by userId?filter argument with an object specifying conditions.filter: { userId: "123" }, which is the correct way to pass filter conditions.subscription { newOrders(filter: { status: "SHIPPED" }) { id status } }status: "SHIPPED", so only orders with this status qualify.subscription { newComments(filter: { postId: 42 }) { id content } }postId, the filter silently blocks updates.tasks but only for tasks assigned to user ID 7 and with priority "HIGH". Which subscription filter is correct?assignedUserId for user ID 7 and priority as "HIGH" string.Pass the test and this pattern moves unknown