Hey all. I am writing integration/functional tests for our graphql endpoint using
WebTestClient
. I configured it to
.accept(MediaType.APPLICATION_JSON)
.contentType(MediaType.APPLICATION_JSON)
I read our test queries and mutations from .graphql files in our Recource directory, massage them to a proper json format (adding "query key and variables), and all worked fine until I got a mutation which has input type like this :
mutation {
addConsumerAddress(data : {
address : "Address location."
setDefault: true
}) {
id
}
}
I can perfectly run this mutation from postman and my mobile clients, but ``WebTestClient` always return
Bad request 400
error.
I solved this by changing setting of webtest client to accept content type graphql
.contentType(MediaType("application", "graphql"))
and passing not formatted String, basically plain .gpaphql file content :
mutation {
addConsumerAddress(data : {
address : "Address location."
setDefault: true
}) {
id
}
}
But just wondering if anyone know what's wrong with MediaType. APPLICATION_JSON or this mutation?