-
-
Notifications
You must be signed in to change notification settings - Fork 535
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added subscription unsubscribing info #3654
Added subscription unsubscribing info #3654
Conversation
Reviewer's Guide by SourceryThis pull request adds documentation about unsubscribing from subscriptions in GraphQL, specifically for Strawberry. The changes include examples of how to unsubscribe in Apollo client and how to handle unsubscription events in Strawberry using Python. No sequence diagrams generated as the changes look simple and do not need a visual representation. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @Bingdom - I've reviewed your changes - here's some feedback:
Overall Comments:
- There's a typo in the word 'supoprts' which should be corrected to 'supports'.
- Consider restructuring the documentation to clearly separate client-side (Apollo) and server-side (Strawberry) examples for better clarity.
Here's what I looked at during the review
- 🟢 General issues: all looks good
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
- 🟡 Documentation: 3 issues found
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
docs/general/subscriptions.md
Outdated
@@ -254,6 +254,52 @@ schema = strawberry.Schema(query=Query, subscription=Subscription) | |||
|
|||
[pep-525]: https://www.python.org/dev/peps/pep-0525/ | |||
|
|||
## Unsubscribing subscriptions | |||
|
|||
In GraphQL, it is possible to unsubscribe from a subscription. Strawberry supoprts this behaviour, and is done using a `try...except` block. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue (documentation): Fix typo in 'supports'
docs/general/subscriptions.md
Outdated
|
||
In GraphQL, it is possible to unsubscribe from a subscription. Strawberry supoprts this behaviour, and is done using a `try...except` block. | ||
|
||
In Apollo-client, closing a subscription can be acheived like the following: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue (documentation): Fix typo in 'achieved'
docs/general/subscriptions.md
Outdated
event_messages = {} | ||
|
||
@strawberry.type | ||
class Subscription: | ||
@strawberry.subscription | ||
async def message(self) -> AsyncGenerator[int, None]: | ||
try: | ||
subId = uuid4() | ||
|
||
event_messages[subId] = [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion (documentation): Clarify the usage of UUID as dictionary key
The code uses a UUID as a key for the event_messages dictionary, but it's not clear where this UUID comes from or how it's generated. Consider adding a brief explanation or comment about this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, but let's double check with @DoctorJohn
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding this to the docs @Bingdom, had to post examples like this many times on Discord in the past few years. I made only one small suggestion, everything else is good to go :)
Thanks for contributing to Strawberry! 🎉 You've been invited to join You can also request a free sticker by filling this form: https://forms.gle/dmnfQUPoY5gZbVT67 And don't forget to join our discord server: https://strawberry.rocks/discord 🔥 |
Description
I added some documentation to detect unsubscribing from subscriptions, to the documentation.
Types of Changes
Checklist
Summary by Sourcery
Update the documentation to include information on unsubscribing from subscriptions in GraphQL, demonstrating the process using Strawberry and Apollo-client.
Documentation: