apollographql / apollographql/graphql-subscriptions
Find no. of clients connected to a subscription
- Dominant language
- TypeScript
- Stars
- 1.6k
- Forks
- 129
- PR merge metrics
- No merged PRs in 30d
Description
I'm building a chat widget where the users will be subscribed to the following subscription. For each user, the 'user_id' will be different
```
subscription {
newUserMessage(user_id: 123) {
id
content
type
}
}
```
I want to find whether a user is online or not. So is there any way to find the number of clients connected to a particular subscription?
My subscription's resolver looks like this:
```
newUserMessage: {
subscribe: withFilter(
() => pubsub.asyncIterator("newUserMessage"),
({ newUserMessage }, args) => {
return args.user_id === newUserMessage.user_id;
}
)
}
```
Contributor guide
Research direction
Start with the shown newUserMessage resolver, especially the withFilter and pubsub.asyncIterator flow, and review how subscription clients are tracked. Define the expected behavior for counting clients or determining presence, then verify it against the subscription example and resolver arguments.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- graphql, node.js, typescript
- Domain
- api, backend-api-design
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100