GraphQL Query Examples
Practical examples of querying workflow instances and task executions using the Data Index GraphQL API.
Basic Queries
Get All Workflow Instances
{
getWorkflowInstances(limit: 10) {
id
namespace
name
status
startDate
endDate
}
}
cURL example:
curl http://localhost:30080/graphql \
-H "Content-Type: application/json" \
-d '{
"query": "{ getWorkflowInstances(limit: 10) { id namespace name status startDate endDate } }"
}'
Response:
{
"data": {
"getWorkflowInstances": [
{
"id": "01KQV3...",
"namespace": "workflows",
"name": "simple-set",
"status": "COMPLETED",
"startDate": "2026-04-27T20:30:00Z",
"endDate": "2026-04-27T20:30:05Z"
}
]
}
}
Get Single Workflow by ID
{
getWorkflowInstance(id: "01KQV3...") {
id
namespace
name
version
status
startDate
endDate
inputData
outputData
}
}
cURL example:
curl http://localhost:30080/graphql \
-H "Content-Type: application/json" \
-d '{
"query": "{ getWorkflowInstance(id: \"01KQV3...\") { id name status inputData outputData } }"
}'
Response:
{
"data": {
"getWorkflowInstance": {
"id": "01KQV3...",
"name": "simple-set",
"status": "COMPLETED",
"inputData": "{\"name\":\"test\",\"value\":42}",
"outputData": "{\"result\":\"success\"}"
}
}
}
|
|
Get Workflows with Tasks
{
getWorkflowInstances(limit: 5) {
id
name
namespace
status
startDate
endDate
taskExecutions {
id
taskName
taskPosition
status
startDate
endDate
}
}
}
cURL example:
curl http://localhost:30080/graphql \
-H "Content-Type: application/json" \
-d '{
"query": "{ getWorkflowInstances(limit: 5) { id name status taskExecutions { id taskName taskPosition status } } }"
}'
Response:
{
"data": {
"getWorkflowInstances": [
{
"id": "01KQV3...",
"name": "simple-set",
"status": "COMPLETED",
"taskExecutions": [
{
"id": "task-1",
"taskName": "set",
"taskPosition": "/do/0",
"status": "COMPLETED"
},
{
"id": "task-2",
"taskName": "set",
"taskPosition": "/do/1",
"status": "COMPLETED"
}
]
}
]
}
}
Task Queries
Get All Task Executions
{
getTaskExecutions(limit: 10) {
id
taskName
taskPosition
status
startDate
endDate
errorMessage
inputData
outputData
}
}
cURL example:
curl http://localhost:30080/graphql \
-H "Content-Type: application/json" \
-d '{
"query": "{ getTaskExecutions(limit: 10) { id taskName taskPosition status startDate endDate } }"
}'
Get Tasks for Specific Workflow
{
getTaskExecutionsByWorkflowInstance(workflowInstanceId: "01KQV3...") {
id
taskName
taskPosition
status
startDate
endDate
inputData
outputData
}
}
cURL example:
curl http://localhost:30080/graphql \
-H "Content-Type: application/json" \
-d '{
"query": "{ getTaskExecutionsByWorkflowInstance(workflowInstanceId: \"01KQV3...\") { id taskName status } }"
}'
Advanced Queries
Filter by Status
{
getWorkflowInstances(
filter: {
status: COMPLETED
}
limit: 20
) {
id
name
status
startDate
endDate
}
}
Available statuses:
-
RUNNING -
COMPLETED -
FAULTED
Filter by Name
{
getWorkflowInstances(
filter: {
name: "simple-set"
}
limit: 10
) {
id
name
namespace
status
}
}
Filter by Namespace
{
getWorkflowInstances(
filter: {
namespace: "workflows"
}
limit: 10
) {
id
name
namespace
status
}
}
Sort by Start Date
{
getWorkflowInstances(
sort: {
field: "startDate"
order: DESC
}
limit: 10
) {
id
name
startDate
status
}
}
Sort orders:
-
ASC- Ascending (oldest first) -
DESC- Descending (newest first)
Pagination
{
getWorkflowInstances(
limit: 20
offset: 40
) {
id
name
status
}
}
This returns results 41-60 (skipping first 40).
Combined: Filter, Sort, and Paginate
{
getWorkflowInstances(
filter: {
namespace: "workflows"
status: COMPLETED
}
sort: {
field: "startDate"
order: DESC
}
limit: 20
offset: 0
) {
id
namespace
name
status
startDate
endDate
taskExecutions {
id
taskName
status
}
}
}
cURL example:
curl http://localhost:30080/graphql \
-H "Content-Type: application/json" \
-d '{
"query": "{ getWorkflowInstances(filter: { namespace: \"workflows\", status: COMPLETED }, sort: { field: \"startDate\", order: DESC }, limit: 20) { id name status startDate taskExecutions { id taskName status } } }"
}'
Common Patterns
Find Failed Workflows
{
getWorkflowInstances(
filter: {
status: FAULTED
}
sort: {
field: "startDate"
order: DESC
}
limit: 10
) {
id
name
namespace
startDate
endDate
taskExecutions {
id
taskName
status
errorMessage
}
}
}
Monitor Running Workflows
{
getWorkflowInstances(
filter: {
status: RUNNING
}
) {
id
name
namespace
startDate
taskExecutions {
id
taskName
taskPosition
status
startDate
}
}
}
Testing Queries
Using GraphiQL (Browser)
Open localhost:30080/graphql in your browser to access the GraphiQL interface:
-
Type your query in the left panel
-
Click "Execute Query" (play button)
-
View results in the right panel
-
Use Docs explorer (top right) to browse schema
Client Libraries
JavaScript/TypeScript
const query = `
{
getWorkflowInstances(limit: 10) {
id
name
status
taskExecutions {
id
taskName
status
}
}
}
`;
const response = await fetch('http://localhost:30080/graphql', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ query })
});
const result = await response.json();
console.log(result.data.getWorkflowInstances);
Python
import requests
import json
query = """
{
getWorkflowInstances(limit: 10) {
id
name
status
}
}
"""
response = requests.post(
'http://localhost:30080/graphql',
headers={'Content-Type': 'application/json'},
json={'query': query}
)
data = response.json()
workflows = data['data']['getWorkflowInstances']
for wf in workflows:
print(f"{wf['id']}: {wf['name']} - {wf['status']}")
Java
import java.net.http.*;
import java.net.URI;
String query = """
{
getWorkflowInstances(limit: 10) {
id
name
status
}
}
""";
String body = String.format("{\"query\": \"%s\"}",
query.replace("\n", " ").replace("\"", "\\\""));
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("http://localhost:30080/graphql"))
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(body))
.build();
HttpResponse<String> response = client.send(request,
HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
Next Steps
-
GraphQL Overview - Schema and types
-
KIND Deployment - Set up local environment for testing
-
Troubleshooting - Common GraphQL issues