GraphQL Tests
Zelte supports full GraphQL testing including queries, mutations, and variables:
collection.yaml
graphql:
- id: get-user
name: Get User Query
endpoint: ${base_url}/graphql
query: |
query GetUser(${id}: ID!) {
user(id: ${id}) {
id
name
email
posts {
id
title
}
}
}
variables:
id: "123"
auth:
type: bearer
token: ${API_TOKEN}
assertions:
- status == 200
- data.data.user.id == "123"Mutations
Test GraphQL mutations the same way:
collection.yaml
graphql:
- id: create-post
name: Create Post Mutation
endpoint: ${base_url}/graphql
query: |
mutation CreatePost($input: CreatePostInput!) {
createPost(input: $input) {
post {
id
title
content
}
}
}
variables:
input:
title: "My First Post"
content: "Hello World"
assertions:
- status == 200
- data.data.createPost.post.id exists