Skip to content

Add headers arg to GraphQLTestCase.query #827

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 26, 2019
Merged

Conversation

chibie
Copy link
Contributor

@chibie chibie commented Dec 15, 2019

Closes #817, closes #824

Now headers can be passed to graphql URL

For example, authorization header can be set thus:

...
response = self.query(
    '''
    mutation updateUser($input: UserUpdateInput!) {
        updateUser(input: $input) {
            ok
            errors {
                field
                messages
            }
        }
    }
    ''',
    op_name='updateUser',
    input_data={
        'firstName': 'Dumebi'
    },
    headers={'HTTP_AUTHORIZATION': f'JWT {token}'}
)

@jkimbo jkimbo self-requested a review December 26, 2019 11:31
Copy link
Member

@jkimbo jkimbo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good thanks @chibie !

@jkimbo jkimbo merged commit b66a3f3 into graphql-python:master Dec 26, 2019
@AliMirjahani
Copy link

Why should we use HTTP_AUTHORIZATION instead of Authorization?

@everdrone
Copy link

everdrone commented Jun 1, 2022

Second this, the HTTP_AUTHORIZATION is undocumented as far as i know.
Why use it instead of Authorization @chibie?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

How to test APIs that require JWT? Add ability to set headers in GraphQLTestCases
4 participants