kubeshop / tracetest

🔭 Tracetest - Build integration and end-to-end tests in minutes, instead of days, using OpenTelemetry and trace-based testing.
https://docs.tracetest.io/
Other
1.07k stars 70 forks source link

Graphql Support #2904

Open k1ng440 opened 1 year ago

k1ng440 commented 1 year ago

Is your feature request related to a problem? Please describe. Right now we have to write multiple lines into a single line using a newline delimiter (\n) in query and it's not convenient to write and maintain them

Describe the solution you'd like Graphql client with introspection support would be nice.

kdhamric commented 1 year ago

We are going to look to add direct capability in the future. For now, I wanted to document the work around that @mathnogueira shared in Discord in case others hit the same issue. If you are reading this with the same issue - leave a note as it will help us prioritize the work!

Here are the notes Matheus shared:

You would only need to send a POST request to your graphql endpoint with the following body:

{ "query": "query{...}" }

replace query{...} with your actual query

For example, I tested it with this graphql example API (https://hub.docker.com/r/favware/graphql-pokemon).

I managed to trigger it with this test:

type: Test
spec:
name: List pokemon
description: List pokemon with GraphQL
trigger:
type: http
httpRequest:
method: POST
url: http://graphql:4000
body: "{\n  \"query\": \"query Query($take: Int, $offset: Int) {getAllPokemon(take: $take, offset: $offset) { color height species } }\",\n  \"variables\": {\"take\": 1, \"offset\": 0}\n}"
headers:
- key: Content-Type
value: application/json
kdhamric commented 1 month ago

Older issue.... but I wanted to mention that we have now added a graphQL trigger to the commercial version of Tracetest. You can read about it here! https://tracetest.io/blog/trace-based-tests-with-graphql-in-action