6

I want to test a GraphQL API. For now, I'm using GraphiQL, but I'm looking for any automated tool... It seems that SOAPUI does not support GraphQL testing.

Any ideas?

Thanks.

Eden G.
  • 105
  • 1
  • 1
  • 4
  • My team had a similar requirement as well, we have written our own tool based on cucumber-jvm, and we have open-sourced it to help others, we've included graphql testing in the latest version. if you are still searching, have a look at https://github.com/JakimLi/pandaria – Jakim May 11 '19 at 07:44
  • 1
    Postman released GraphQL support on their canary channel - https://www.getpostman.com/downloads/canary – Sivcan Singh May 29 '19 at 05:52

5 Answers5

3

You basically have a few options that I've seen:

  1. Apollo's GraphQL Platform. It gives you full-blown telemetry on your individual resolvers, and can integrate with VS Code to let your developers know how expensive their query is in real time. You'll pay for it though.

  2. An observation tool such as HoneyComb or DataDog, also paid.

  3. Write your own. For a simple enough use-case it may make sense, but if you're looking for a rich feature set it probably makes more sense to buy rather than to build.

RozenMD
  • 325
  • 3
  • 10
3

I am using SoapUI 5.4.0 (community edition) and have no trouble testing GraphQL requests. Treat them as a Rest request and add a header, e.g. Content-Type: application/graphql

see image for all details.

SoapUI GraphQL example

Angel F Syrus
  • 1,984
  • 8
  • 23
  • 43
  • This only works if the server side accepts application/graphql Many servers tend to remain standard and accept the json format – Payam Jul 30 '20 at 19:45
1

What, specifically, do you want to test?

We have a number of automated sanity-check tests that we run on every build:

  1. Is the schema valid (according to graphql-js)? This can be surprisingly easy to mess up if your implementation allows for e.g. multiple definitions of the same type name, or any other number of subtle bugs.

  2. Is this a breaking schema change? If so, break the build unless there's a specific git commit message acknowledging and accepting it. With graphql-js this is fairly easy - run the introspection query against current production, run it against the current build, and use the built in findBreakingChanges function.

Note that the graphql-js tests don't mean your server has to be written in JS - ours is written in ReasonML using ocaml-graphql-server, and then on build we use a node test suite to hit it as any other client would.

Finally, beyond that, we have some tests that run queries/mutations for an end-to-end API server test. Overall, this has been quite robust against regressions so far.

And keep in mind that you can simply hit your GraphQL server with any http client, there doesn't have to be GraphQL-awareness in your test suite. I'd recommend this route on top of the sanity checks I mentioned above.

sgrove
  • 1,149
  • 2
  • 11
  • 23
  • Thank you for your answer but I'm asking about automation tools for testing the server's response for a GraphQL query. – Eden G. Nov 25 '18 at 12:07
0

For automated testing there is https://github.com/ohler55/graphql-test-tool/gtt. It's written in go but as a standalone application it can be used with any GraphQL server. We use it for unit testing and CI.

Peter Ohler
  • 171
  • 1
  • 4
-2

Karate is the only open-source tool to combine API test-automation, mocks and performance-testing into a single, unified framework.

https://github.com/intuit/karate

Ashwini
  • 11