apollographql / apollographql/graphql-subscriptions

How to trigger side effect after subscribe to channel?

Open
#281 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
1.6k
Forks
129
PR merge metrics
No merged PRs in 30d

Description

Hello. How i can achieve this right after I subscribe to trigger a callback function that will f.ex do a api-request to some endpoint?

So I have this like this:
` Subscription: {
myQuery: {
subscribe: ()=>pubsub.asyncIterator(channelId);,
resolve: (payload: myType) => {
return payload
},
},
},`

I would like right after I register/subscribe to channel to trigger it so somehow after
`pubsub.asyncIterator(channelId)` this line runs. I tried some hacky solution with setTimeout but that is not good one.

Contributor guide

Open the contributing guide

Research direction

Start with the Subscription configuration and the pubsub.asyncIterator(channelId) entry point shown in the issue. Determine whether the library exposes a supported post-subscription callback or hook, and document the expected behavior and completion criteria; no file or test is identified in the report.

Written by the indexing model from the issue text.

Assessment

Tech stack
graphql, node.js, typescript
Domain
api, backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.