Skip to content

GraphQLTestCase does not send headers using Django 4.2 #1464

Closed
@ryanovas

Description

@ryanovas
  • What is the current behavior?

Trying to send headers using GraphQLTestCase doesn't work. This is my test:

class TestCase(GraphQLTestCase):
    def test(self):
        response = self.query(
            '''
            query {
                puzzles {
                    id
                    title
                }
            }
            ''',
            headers={
                'Some-Header': 'test,
            },
        )

        self.assertResponseNoErrors(valid_response)

and if I try to log those headers in my code I get None. However if I follow the code to graphene_django/utils/testing.py and change line 58 from:

resp = client.post(
            graphql_url, json.dumps(body), content_type="application/json", **headers
        )

to

resp = client.post(
            graphql_url, json.dumps(body), content_type="application/json", headers=headers
        )

Then it works fine.

  • Please tell us about your environment:

    • Version:

python = "^3.11"
django = "^4.2.1"
graphene-django = "^3.1.1"

  • Platform: Ubuntu

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions