Skip to main content

GraphQL

This blog post describes the basics of how to test GraphQL with Pact. TL;DR - GraphQL is just a HTTP API, so you can use Pact to test it just like any other HTTP API.

If you use query string based GraphQL, it should work pretty much out of the gate. If you use POST based GraphQL, you might like to create a utility function to wrap the HTTP requests to reduce some boilerplate.

Some languages have a GraphQL interface added for convenience, such as Pact JS and Pact Go. You can review their implementations to add support to your language as needed:

Examples​