WireMock and GraphQL
Documentation / java / solutions / graphql
WireMock Cloud
Mock your GraphQL endpoints in WireMock Cloud with instant mock data and federated supergraph
WireMock Extension
There is a GraphQL extension for WireMock that allows semantically matching GraphQL queries, regardless of the order of the fields in the original request. It brings powers of request matching and response templating to the GraphQL query language.
Example:
Kotlin
import com.github.tomakehurst.wiremock.client.WireMock
import com.github.tomakehurst.wiremock.client.WireMock.*
import io.github.nilwurtz.GraphqlBodyMatcher
fun registerGraphQLWiremock(json: String) {
WireMock(8080).register(
post(urlPathEqualTo(endPoint))
.andMatching(GraphqlBodyMatcher.extensionName, GraphqlBodyMatcher.withRequest(json))
.willReturn(
aResponse()
.withStatus(200)
)
)
}
Read More
- GraphQL API mocking with the new WireMock extension blogpost by Eiki Hayashi
- GitHub repository with documentation