apollographql / apollographql/graphql-subscriptions
graphql-subscriptions is not working consistently.
- Dominant language
- TypeScript
- Stars
- 1.6k
- Forks
- 129
- PR merge metrics
- No merged PRs in 30d
Description
Hi all,
We are using PubSub in our application in this manner:
**When deletion event is arriving into server:**
`pubsub.publish('onDeleteItem', {onDeleteItem: [msg.payload.ItemId]});`
**Resolvers:**
` Subscription: {
onDeleteItem: {
subscribe: () => pubsub.asyncIterator('onDeleteItem'),
},
},`
**Subscribing to it from our client side:**
` const onDeleteItemSubscription = gql`
```
subscription onDeleteItem {
onDeleteItem
}
getItemsList () {
queryRef.subscribeToMore({
document: onDeleteItemSubscription ,
updateQuery(prev: { itemList: AssetList }, {subscriptionData: {data}}) {
if (!data) {
return prev;
} else {
const deletedItems = (data as any).onDeleteItem;
return {
itemList {... ### //return filtered list
}
}
}
}
}
```
`;`
The problem is that sometimes the subscription is working fine and the deleted item is filtered as expected, but very often it just not working at all. There are no error logs.
When I debug it, I can see that the problem is that the client is not notified by pubsub.publish()
The problem is occurring with all our subscriptions and this is only one example of them.
What am I missing here?
Thanks.
Contributor guide
Research direction
Start by reproducing the shown flow from pubsub.publish() through pubsub.asyncIterator() and the client’s subscribeToMore() updateQuery callback. Compare successful and missed deletion events across the reported subscriptions, using the absence of client notifications as the observable symptom; done means the cause is identified and notifications are delivered consistently or the missing setup is documented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- graphql, node.js, typescript
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100