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"
}

SpringBoot GraphQL should reply with HTTP 415 for unsupported content type

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.

Comment From: bclozel

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.