-
Notifications
You must be signed in to change notification settings - Fork 21
added support in requests.Session #58
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
base: master
Are you sure you want to change the base?
Conversation
@uriyay thanks for the contribution, however this change as you can see breaks tests on the existing functionality. We should potentially introduce checking if session is the instance of Session. If it is not then we perform the default requests.post. If session is the instance of Session then we can produce a session.post. Note please include tests to cover these scenarios. |
…n. added tests for testing client.execute() with a given session object
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 the update. I left some feedback on the changes.
**kwargs: Any, | ||
): | ||
"""Make synchronous request to graphQL server.""" | ||
request_body = self.__request_body( | ||
query=query, variables=variables, operation_name=operation_name | ||
) | ||
|
||
result = requests.post( | ||
post_method = requests.post | ||
if session: |
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 should validate the type that session is a Session to prevent injection.
if session: | |
if isinstance(session, Session): |
Co-authored-by: Justin Krinke <[email protected]>
What kind of change does this PR introduce?
Added support in requests.Session in order to solve #54
What is the current behavior?
client.execute() calls to requests.post(), using a session object is not available.
What is the new behavior?
client.execute() gets a new parameter named
session
that holds a Session object that will be used for making the POST request.The new parameter is None by default, if its None a new session is created and will be used for making the POST request.
Does this PR introduce a breaking change?
No, you can still skip passing session parameter and the code will act the same as before.
Other information
This feature allows users to:
Don't override
Authorization
header when contents are bearer token (or any other token) psf/requests#3929