Example plan

graphql.yaml

New here? Get started. See Running the examplesfor this plan's fixture, runtime, database or browser requirements. The exec example needs no fixture; Postgres and Playwright need their optional dependencies.

A graphql step posts a query with variables and reads the data back; a second task expects an error and says so by reading body.errors, which is what turns the step's own errors check off. Start bin/vero-testserver in Terminal 1 in the foreground; run bin/vero run examples/graphql.yaml in Terminal 2. The fixture's /fixtures/graphql echoes the query it got, or answers with an errors array when the variables carry a fail message.

apiVersion: vero.plan/v1
kind: Plan
metadata: { name: example-graphql }
env:
  baseUrl: http://127.0.0.1:18080
lifecycle: { strategy: isolated }   # the fixture keeps nothing from a graphql call

tasks:
  - name: order-query
    steps:
      - graphql:
          url: "{{ env.baseUrl }}/fixtures/graphql"
          query: |
            query GetOrder($id: ID!) {
              order(id: $id) { id status }
            }
          operationName: GetOrder
          variables: { id: "ord-{{ run.id }}" }
        assert:
          - status == 200
          - body.data.echo.operationName == "GetOrder"
          - body.data.echo.variables.id startsWith "ord-"
        results:
          variables: body.data.echo.variables

  - name: order-not-found
    steps:
      - graphql:
          url: "{{ env.baseUrl }}/fixtures/graphql"
          query: "{ order(id: \"missing\") { id } }"
          variables: { fail: "order not found" }
        assert:
          - status == 200
          - body.data == nil
          - body.errors[0].message == "order not found"
          - body.errors[0].path == ["order"]

This page is examples/graphql.yaml in the repository.

verodocs