Skip to content

Servlet fails to recognize application/graphql when charset is specified #471

Closed
@JariNestel

Description

@JariNestel

Describe the bug
When sending POST requests to the GraphQL Servlet with Content-Type: application/graphql it works as expected, when specifying a charset with Content-Type: application/grapql; charset=utf-8 it fails to recognize it and tries to handle it as a JSON body instead.

To Reproduce
Steps to reproduce the behavior:

  1. Make any queryable GraphQL Servlet
  2. Query it via POST with Content-Type: application/graphql; charset=utf-8
  3. GraphQLPostInvocationInputParser fails to recognize Content-Type Header

Expected behavior
GraphQLPostInvocationInputParser should be able to handle Content-Type Headers containing additional information like charset

Additional context
Currently checking for Content-Type: application/graphql in GraphQLPostInvocationInputParser happens like this:

if (APPLICATION_GRAPHQL.equals(request.getContentType())) {

I would expect something more like this:

String contentType = request.getContentType();
if (contentType != null && APPLICATION_GRAPHQL.equals(contentType.split(";")[0])) {

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions