Skip to content
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

fix: fix graphiql request failure #1404

Merged
merged 2 commits into from
May 3, 2023
Merged

fix: fix graphiql request failure #1404

merged 2 commits into from
May 3, 2023

Conversation

kiendang
Copy link
Collaborator

@kiendang kiendang commented May 2, 2023

Fix #1402

After upgrading GraphiQL to v2.4.1 (#1396) all requests seem to fail on Chrome and Safari but works on Firefox. Unfortunately while working on that PR I tested exclusively on Firefox and didn't catch this.

The problem seems to be caused by this line.

headers['Content-Type'] = headers['Content-Type'] || 'application/json';

Also took this opportunity to simplify the GraphQL fetcher logic. Accept and Content-Type are automatically taken care of and don't need setting explicitly.

A more detailed explanation of the bug: content-type: application/json is automatically added and so we have both content-type and Content-Type in the headers object which somehow got turned into content-type: application/json, application/json which is invalid.

@sparktx-adam-gleason @dicknetherlands could you help test this with

pip install git+https://github.com/graphql-python/graphene-django.git@graphiql-headers-fix

@dicknetherlands
Copy link

This fix works for me (Chrome on Mac).

@sparktx-adam-gleason
Copy link

This fix also works for me (Brave on Mac)

@firaskafri firaskafri changed the base branch from main to v2 May 3, 2023 06:53
@firaskafri firaskafri changed the base branch from v2 to main May 3, 2023 06:53
Copy link
Collaborator

@jaw9c jaw9c left a comment

Choose a reason for hiding this comment

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

Looks good, nice cleanup too 👍

@kiendang kiendang mentioned this pull request May 3, 2023
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.

GraphiQL v2.4.1 won't run IntrospectionQuery properly
5 participants