Skip to content

Commit beb2e4a

Browse files
authored
Doc clarification for headers arg in testing utils (#1117)
I think it might be helpful to add an explicit hint that HTTP headers should be prepended with `HTTP_` as required by `django.test.Client` (at least it was not super obvious to me when I tried to use it).
1 parent 5288016 commit beb2e4a

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

graphene_django/utils/testing.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ def graphql_query(
2828
variables (dict) - If provided, the "variables" field in GraphQL will be
2929
set to this value.
3030
headers (dict) - If provided, the headers in POST request to GRAPHQL_URL
31-
will be set to this value.
31+
will be set to this value. Keys should be prepended with
32+
"HTTP_" (e.g. to specify the "Authorization" HTTP header,
33+
use "HTTP_AUTHORIZATION" as the key).
3234
client (django.test.Client) - Test client. Defaults to django.test.Client.
3335
graphql_url (string) - URL to graphql endpoint. Defaults to "/graphql".
3436
@@ -85,7 +87,9 @@ def query(
8587
variables (dict) - If provided, the "variables" field in GraphQL will be
8688
set to this value.
8789
headers (dict) - If provided, the headers in POST request to GRAPHQL_URL
88-
will be set to this value.
90+
will be set to this value. Keys should be prepended with
91+
"HTTP_" (e.g. to specify the "Authorization" HTTP header,
92+
use "HTTP_AUTHORIZATION" as the key).
8993
9094
Returns:
9195
Response object from client

0 commit comments

Comments
 (0)