You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What is the current behavior?
This is with graphene-django==3.2.0 and Django==4.2.10 and it concerns the graphql_query function from graphene_django.utils.testing. Django 4.2.+ prefixes the header keys automatically with HTTP_, making the documentation of the graphql_query in that situation wrong.
c = Client()
c.get(
... "/customers/details/",
... {"name": "fred", "age": 7},
... headers={"accept": "application/json"},
... )
…will send the HTTP header HTTP_ACCEPT to the details view, which is a good way to test code paths that use the django.http.HttpRequest.accepts() method.
Fix
So I suggest at a minimum to update the documentation / description of client_query that with Django 4.2+ headers don't have to be prefixed with HTTP_. Ideally the function it self would take care of it however.
Ah ok this is valid. I didn't read the Django doc carefully when doing #1465. I think the correct solution to this is to revert #1465 and add a check making sure that headers keys all start with HTTP_. What do you think?
What is the current behavior?
This is with
graphene-django==3.2.0
andDjango==4.2.10
and it concerns thegraphql_query
function fromgraphene_django.utils.testing
. Django 4.2.+ prefixes the header keys automatically withHTTP_
, making the documentation of thegraphql_query
in that situation wrong.Pseudo Code:
If we then later dump
request.META
we will seeHTTP_HTTP_AUTHORIZATION
.The part of graphene where it handles the Django version can be found here:
graphene-django/graphene_django/utils/testing.py
Line 60 in 4d0484f
Further context
You see Django's behavior described here in an example: https://docs.djangoproject.com/en/4.2/topics/testing/tools/#django.test.Client.get
Fix
So I suggest at a minimum to update the documentation / description of
client_query
that with Django 4.2+ headers don't have to be prefixed with HTTP_. Ideally the function it self would take care of it however.graphene-django/graphene_django/utils/testing.py
Lines 33 to 36 in 4d0484f
The text was updated successfully, but these errors were encountered: