With a REST API and Spring Boot WebTestClient I can easily get back the object parsed from the returned JSON like this:
Person person = webTestClient
.get()
.uri("/person/3")
.exchange()
.expectBody(Person.class))
.returnResult()
.getResponseBody();
With graphql the json is wrapped inside of a data attribute like this:
{
"data" : {
"person" : {
"name" : "Foo"
}
}
So it doesn't work with
...
.expectBody(Person.class))
as the JSON parser is starting with "data" and not with "data.person".
How to achieve this to parse the JSON result directly and return the Person object?