Skip to navigation

GraphQL Query Examples

Beta
Common query patterns for the Sample GraphQL API
View as Markdown

This page provides example queries you can use with the Sample GraphQL API. Each example includes the query, variables, and expected response.

Query Examples

Retrieve a single user with all their fields:

query GetUser($id: ID!) {
user(id: $id) {
id
name
email
role
createdAt
}
}

Variables:

{
"id": "usr_abc123"
}

Response:

{
"data": {
"user": {
"id": "usr_abc123",
"name": "Jane Smith",
"email": "jane@example.com",
"role": "EDITOR",
"createdAt": "2025-01-15T10:30:00Z"
}
}
}

Error Handling

GraphQL errors are returned in the errors array alongside partial data:

{
"data": {
"user": null
},
"errors": [
{
"message": "User not found",
"path": ["user"],
"extensions": {
"code": "NOT_FOUND"
}
}
]
}