🏗️ Architecture

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

FeatureGraphQLREST
Data fetchingClient specifies shapeFixed responses
Over-fetchingNoCommon
Under-fetchingNoRequires joins
TypingStrong schemaOpenAPI/Swagger
CachingMore complexStandard HTTP cache

Edit this page

Copyright © 2023-Present Ever Co. LTD.Docs by Sourcey