This repository was archived by the owner on Oct 11, 2025. It is now read-only.

Description
Implementing complete GraphQL support involves reading the request body and considering it as the query for one special case. In a controller, this means using request.reader.text.
def index() {
def body = request.reader.text
respond body
}
In a test class the controller method is called multiple times as there are multiple tests.
def "test"() {
when:
controller.index()
then:
true
}
def "test2"() {
when:
controller.index()
then:
true
}
This is a problem when the body is empty. When executing the second test, it fails with java.io.IOException: Stream closed. The tests are not independent.
Please note that when the body is not empty, i.e.
request.json = [hello: "world"]
the tests pass.
Please also note that replacing request.reader.text with request.JSON in the controller causes the tests to pass. This is specifically for reading the body text.