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.
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.
You basically have a few options that I've seen:
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.
An observation tool such as HoneyComb or DataDog, also paid.
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.
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.
What, specifically, do you want to test?
We have a number of automated sanity-check tests that we run on every build:
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.
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.
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.
Karate is the only open-source tool to combine API test-automation, mocks and performance-testing into a single, unified framework.