GraphQL Integration Testing

September 9, 2018
GraphQL Integration Testing

One of the touted GraphQL features is that you never need to version your API again. Simply add new fields with non-conflicting names and old clients will chuck along like nothing changed. And because GraphQL works on fields not endpoints clients won't be doing over fetch.

This is indeed a great feature, but for it to fully hold true we need those fields to return consistent data over time. Sounds like we need some tests.

At DueDil we write integration tests for every part of our schema as we develop it. I imagine this is partly because we made it extremely easy to add integration tests early on. Today we're open sourcing our small integration testing tool in the hopes that others will find it useful.

You can find out more about it on github.

The basics

Adding an integration test for a new feature is as simple as creating a new file and pasting a query and an expected response.

query CompanyExample {
   company(id: "company/gb/06999618") {
       name {
   "data": {
       "company": {
           "name": {
               "DueDil Limited"

Running graphqltester -v '' will now run your tests in parallel and give you a diff on failure.

Example run of graphqltester

For the adventurous

I would advice having a look at the README for examples of how graphqltester can be used. But here's an overview of supported features:

  • run a specific suites
  • run a single test
  • run all tests matching a wildcard search
  • run tests and update the expectations on failure
  • run tests against a regression server

Interested in working with GraphQL? Join us, we're hiring.

Sign up to the latest DueDil news!
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.