python-graphql-client
python-graphql-client copied to clipboard
added support in requests.Session
What kind of change does this PR introduce?
Added support in requests.Session in order to solve https://github.com/prodigyeducation/python-graphql-client/issues/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:
- Log in with a complex flow such as oidc, that sets an authorization cookies for the session
- Prevent requests from using .netrc file by default, by setting session.trust_env to False: https://github.com/psf/requests/issues/3929
@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.