From bc20a389362af5b6fa7d2d5df403835df3af47b3 Mon Sep 17 00:00:00 2001 From: "st. chibie" Date: Sat, 14 Dec 2019 18:04:44 +0100 Subject: [PATCH] Add headers arg to GraphQLTestCase.query --- graphene_django/utils/testing.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/graphene_django/utils/testing.py b/graphene_django/utils/testing.py index 5b694b2..89b293c 100644 --- a/graphene_django/utils/testing.py +++ b/graphene_django/utils/testing.py @@ -24,7 +24,7 @@ class GraphQLTestCase(TestCase): cls._client = Client() - def query(self, query, op_name=None, input_data=None, variables=None): + def query(self, query, op_name=None, input_data=None, variables=None, headers=None): """ Args: query (string) - GraphQL query to run @@ -36,7 +36,9 @@ class GraphQLTestCase(TestCase): are provided, the ``input`` field in the ``variables`` dict will be overwritten with this value. variables (dict) - If provided, the "variables" field in GraphQL will be - set to this value. + set to this value. + headers (dict) - If provided, the headers in POST request to GRAPHQL_URL + will be set to this value. Returns: Response object from client @@ -53,7 +55,7 @@ class GraphQLTestCase(TestCase): body["variables"] = {"input": input_data} resp = self._client.post( - self.GRAPHQL_URL, json.dumps(body), content_type="application/json" + self.GRAPHQL_URL, json.dumps(body), content_type="application/json", **headers ) return resp