Skip to content

WebGraphQlRequest operation(Name) incorrect when multiple queries submitted from GraphiQl interface #741

Closed as not planned
@dbarnhoorn

Description

@dbarnhoorn

The current GraphiQl interface and WebGraphQlRequest are not compatible

spring-graphql 1.1.3 retrieved the key 'operationName' from the post body:
getKey("operationName", body) [in the call to super on line 87]

whilst the current implementation retrieves 'operation':
Object value = body.get("operation"); [in the getOperation method on line 108]

GraphiQl sends a json body containing 'operationName' and 'query' keys and with the current version that results in a
"graphql.execution.UnknownOperationException: Must provide operation name if query contains multiple operations." when sending a document with multiple queries.

I think operationName is the correct name looking at graphql.org, if so the fix would be in retrieving the correct key from the body, otherwise an update to the graphiql javascript (and a change to include that version in the graphiql.html) is probably the solution. (Supporting two keys in case one of the two is empty does not sound like a good solution to me)

Reproducable by starting a project with spring-graphql-1.2.1 and an enabled graphiql interface (spring.graphql.graphiql.enabled: true) and a schema and pasting a simple schema query in the left pane:

query schema1 {
  __schema{
    queryType {
      fields {
        name
      }
    }
  }
}
query schema2 {
  __schema{
    queryType {
      fields {
        name
      }
    }
  }
}

then choosing either of the queries in the dropdown that appears when clicking the 'play' button.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions