-
-
Notifications
You must be signed in to change notification settings - Fork 509
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 an option to pass connection params when initiating connection … #3403
Added an option to pass connection params when initiating connection … #3403
Conversation
…on strawberry channels test case
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.
We have skipped reviewing this pull request. All the files appear to be test files, which we're not great at reviewing... yet!
Thanks for adding the Here's a preview of the changelog: This release adds support to allow passing ExampleGraphQLWebsocketCommunicator(
application=application,
path="/graphql",
connection_params={"username": "strawberry"},
) Here's the tweet text:
|
Im following https://strawberry.rocks/docs/integrations/channels#testing to write test cases for my app. I noticed that there is no parameter/method to pass connection_params when initiating the connection. In https://github.com/strawberry-graphql/strawberry/blob/main/strawberry/channels/testing.py file, on method gql_init() line 102, we are directly passing connection init message without any possibility to pass connection_params. |
Thanks for the PR @selvarajrajkanna . Would you be interested in adding a test case for this? :) (The test case could for example test sending connection init params and then querying them via a resolver) Yup, we even have tests for the testing module. They can be found here: https://github.com/strawberry-graphql/strawberry/blob/main/tests/channels/test_testing.py |
for more information, see https://pre-commit.ci
…selvarajrajkanna/strawberry into channels-test-connection-params
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #3403 +/- ##
==========================================
+ Coverage 95.35% 96.40% +1.05%
==========================================
Files 498 498
Lines 31131 31137 +6
Branches 3809 3815 +6
==========================================
+ Hits 29685 30019 +334
+ Misses 1237 912 -325
+ Partials 209 206 -3 |
@DoctorJohn Added test case :) |
CodSpeed Performance ReportMerging #3403 will improve performances by 37.04%Comparing Summary
Benchmarks breakdown
|
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.
Excellent, thanks for adding tests and the code optimization @selvarajrajkanna! I just noticed mentioning this in our docs would be great too. You're the expert on these changes so if you're interesting in adding a secting to the testing docs, feel free to do so. We'll merge this PR shortly. Let me know whether you would be interested in adding docs. That could either be done in one go with this PR or a separate one.
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! I left a couple of changes for the changelog 😊
for more information, see https://pre-commit.ci
@patrick91 updated the RELEASE.md file with recommendation :) |
@DoctorJohn , Documentation isn't exactly my jam, but I'm a quick learner. Mind pointing me in the right direction? |
Gladly! Our documentation is written in markdown. The Channels documentation can be found under docs/integrations/channels. There is already a testing section. Therefore it would be sufficient to add a small subsection that mentions that connection init params can be passed and then possibly the code sample you already have in the RELEASE.md file. Could look something like this: ### Passing connection params
Connection parameters can be passed using the `connection_params` parameter of the `GraphQLWebsocketCommunicator` class. This is particularily useful to test websocket authentication.
```python
GraphQLWebsocketCommunicator(
application=application,
path="/graphql",
connection_params={"token": "strawberry"},
)
``` |
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
@DoctorJohn , Essentially added your suggestion to the doc :) |
Awesome, thank you! I moved the new section in the docs a little further down so that the new subheading is scoped correctly. This is good to go now. |
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 🔥 |
…on strawberry channels test case
Description
Types of Changes
Issues Fixed or Closed by This PR
Checklist