GraphQL API Overview
Using the Gauzy GraphQL API alongside the REST API.
Endpointβ
POST /graphql
GraphQL Playground: http://localhost:3000/graphql
Authenticationβ
Include JWT token in the request headers:
{
"Authorization": "Bearer YOUR_TOKEN"
}
Example Queriesβ
Fetch Employeesβ
query {
employees(
filter: { organizationId: "org-uuid", isActive: true }
paging: { limit: 10, offset: 0 }
) {
edges {
node {
id
user {
firstName
lastName
email
}
startedWorkOn
isActive
}
}
totalCount
}
}
Fetch Tasksβ
query {
tasks(
filter: { projectId: "project-uuid", status: "TODO" }
sorting: [{ field: createdAt, direction: DESC }]
) {
edges {
node {
id
title
status
priority
assignees {
id
user {
firstName
lastName
}
}
}
}
totalCount
}
}
Mutationsβ
Create Taskβ
mutation {
createOneTask(
input: {
task: {
title: "New Task via GraphQL"
status: "TODO"
priority: "HIGH"
projectId: "project-uuid"
organizationId: "org-uuid"
tenantId: "tenant-uuid"
}
}
) {
id
title
status
}
}
Update Employeeβ
mutation {
updateOneEmployee(
input: { id: "employee-uuid", update: { isActive: false } }
) {
id
isActive
}
}
Subscriptionsβ
subscription {
timerStatusChanged {
employeeId
running
duration
}
}
GraphQL vs RESTβ
| Feature | GraphQL | REST |
|---|---|---|
| Data fetching | Client specifies shape | Fixed responses |
| Over-fetching | No | Common |
| Under-fetching | No | Requires joins |
| Typing | Strong schema | OpenAPI/Swagger |
| Caching | More complex | Standard HTTP cache |
Related Pagesβ
- API Overview β REST API
- Pagination & Filtering β query patterns