apollographql / apollographql/graphql-subscriptions
Documentation for subscription resolver is misleading, suggested change
- Dominant language
- TypeScript
- Stars
- 1.6k
- Forks
- 129
- PR merge metrics
- No merged PRs in 30d
Description
Old Example
```
const SOMETHING_CHANGED_TOPIC = "something_changed"
export const resolvers = {
Subscription: {
somethingChanged: {
subscribe: () => pubsub.asyncIterator(SOMETHING_CHANGED_TOPIC),
},
},
}
```
Replace it with:
```
export const resolvers = {
Subscription: {
somethingChanged: {
subscribe: (root, args, ctx, info) => pubsub.asyncIterator(args.topicName),
},
},
}
```
and mention that the subscription resolver gets called once per change to the subscriptions variables on the component; and is responsible for returning an asyncIterator which in turn pushes messages out to subscribers.
Note that the pubsub topic name is no longer hard coded and can be some function of args, and ctx similar to all other resolvers.
Contributor guide
Research direction
Locate the documentation section containing the subscription resolver example and compare the old and suggested snippets in this issue. Update the example and explain that the resolver runs when subscription variables change, returns an asyncIterator, and can derive the topic from args and ctx; verify the rendered documentation reads correctly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- graphql, typescript
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100