Hey all. I am writing integration/functional tests...
# graphql-kotlin
m
Hey all. I am writing integration/functional tests for our graphql endpoint using
WebTestClient
. I configured it to
Copy code
.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 :
Copy code
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
Copy code
.contentType(MediaType("application", "graphql"))
and passing not formatted String, basically plain .gpaphql file content :
Copy code
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?
d
I'd recommend to use our gql spring client instead
That being said I'd double check the payload if you are posting a valid json
As it should work with plain webclient
m
Do you have a link to your gql spring client? I might check it.
But you gave me an idea, I might need to ecranize quads. Non of my queries and mutations had it before.