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

feat(body-parsing): support the application/graphql+json content-type #6295

Closed
wants to merge 4 commits into from

Conversation

JoviDeCroock
Copy link
Contributor

This PR aims to add support for the application/graphql+json content-type, this has been added to the spec here we see that we can support both application/json and application/graphql+json.

The main issue seems to be related to the body-parser used in koa and express as well as a check used in micro, an alternative would be to introduce a new body-parser.

@codesandbox-ci
Copy link

codesandbox-ci bot commented Apr 5, 2022

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 76d03bf:

Sandbox Source
Apollo Server Typescript Configuration
Apollo Server Configuration

@netlify
Copy link

netlify bot commented Apr 5, 2022

👷 Deploy request for apollo-server-docs pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit b5f3c0d

@netlify
Copy link

netlify bot commented Apr 5, 2022

👷 Deploy request for apollo-server-docs pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 76d03bf

Copy link

@kettanaito kettanaito left a comment

Choose a reason for hiding this comment

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

🎉

@glasser
Copy link
Member

glasser commented Apr 8, 2022

Huh, that's news to me. Kinda surprised that the HTTP wg folks didn't reach out to server implementers when making that proposal, though maybe they did and we missed it. I think it's honestly a bummer to make this choice which means that GraphQL servers won't work with web framework JSON parsing libraries without extra configuration. In AS4 we are actually moving responsibility for JSON parsing out of our code and making it the users' responsibility (unless using the new ApolloServerStandalone class) and it's going to be annoying that the setup code for users will need to pass in this extra flag instead of just being json(). Is there a document available somewhere explaining the motivation for this change? What other servers already implement this?

@glasser
Copy link
Member

glasser commented Apr 8, 2022

I also note that it's not registered with IANA.

@JoviDeCroock
Copy link
Contributor Author

JoviDeCroock commented Apr 8, 2022

Registering to IANA is on the issues currently graphql/graphql-over-http#31 the main driving factor was to have a unique way to identify graphql requests over http. I think other servers support the content-type implicitly as in they don't throw, apollo-server does not parse the json in this case

@glasser
Copy link
Member

glasser commented Oct 19, 2022

The spec has been updated to no longer encourage the use of a custom request type (just a custom response type, which is supported in AS4).

@glasser glasser closed this Oct 19, 2022
@glasser
Copy link
Member

glasser commented Oct 19, 2022 via email

@kettanaito
Copy link

kettanaito commented Oct 19, 2022

Such a sad development from the GraphQL specification :( It's year 2022 and you still cannot reliably tell apart a GraphQL request from a seemingly compatible generic HTTP request.

Although you can try inferring that from the request's Accept: application/graphql-response+json but that is not mandatory. Everything optional may and will be overlooked.

Maybe one day.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants