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

GraphQL should reply with HTTP 415 for unsupported content type #41675

Closed
nictas opened this issue Jul 31, 2024 · 1 comment
Closed

GraphQL should reply with HTTP 415 for unsupported content type #41675

nictas opened this issue Jul 31, 2024 · 1 comment
Assignees
Labels
type: enhancement A general enhancement
Milestone

Comments

@nictas
Copy link

nictas commented Jul 31, 2024

Hi,

I receive a 404 response when I try to make a request to the /graphql endpoint with a wrong content type (text/plain, for example):

{
	"timestamp": "2024-07-31T15:49:28.136+00:00",
	"status": 404,
	"error": "Not Found",
	"path": "/graphql"
}

image

This is a bit confusing because it leads you to think that there's something wrong with the GraphQL configuration in the application, whereas the actual problem is with the request.

I'm using version 3.3.2 of spring-boot-starter-graphql. The problem should be reproducible with any sample project but I'll attach my own just in case:
graphql-demo.zip

You can execute a GraphQL request with the following body to reproduce the issue:

{"query":"query getCurrentUser {\n\tgetCurrentUser \n}","operationName":"getCurrentUser"}

The authentication is basic with a username of "user" and the password written in the application logs.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jul 31, 2024
@bclozel bclozel self-assigned this Jul 31, 2024
@bclozel bclozel transferred this issue from spring-projects/spring-graphql Aug 1, 2024
@bclozel bclozel added type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged labels Aug 1, 2024
@bclozel bclozel added this to the 3.4.0-M2 milestone Aug 1, 2024
@bclozel
Copy link
Member

bclozel commented Aug 1, 2024

This is actually a Spring Boot enhancement, I've moved the issue accordingly.
In this case, we should return an HTTP 415 status and an "Accept" header that reflects what's expected.

@bclozel bclozel changed the title /graphql endpoint responds with 404 when using an incorrect content type GraphQL should reply with HTTP 415 for unsupported content type Aug 1, 2024
@bclozel bclozel closed this as completed in 1738e0c Aug 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

3 participants