DocsGraphQL

GraphQL API

Full GraphQL support with queries, mutations, and real-time subscriptions. Schema automatically generated from your PostgreSQL database.

Endpoints

POST /api/graphql

Execute GraphQL queries and mutations

GET /api/graphql

GraphQL Playground (interactive IDE)

WS /api/graphql/ws

WebSocket endpoint for real-time subscriptions

Queries

GraphQL
# Basic query
query {
  users {
    id
    name
    email
  }
}

# With filtering and pagination
query {
  users(
    filter: { status: { eq: "active" } }
    limit: 10
    offset: 0
    orderBy: { createdAt: DESC }
  ) {
    id
    name
    email
    createdAt
  }
}

# Nested relationships
query {
  orders {
    id
    total
    customer {
      name
      email
    }
    items {
      quantity
      product {
        name
        price
      }
    }
  }
}

Mutations

GraphQL
# Insert single record
mutation {
  insertUserOne(objects: {
    name: "Alice",
    email: "alice@example.com"
  }) {
    id
    name
    email
  }
}

# Insert multiple records
mutation {
  insertUsers(objects: [
    { name: "Alice", email: "alice@example.com" },
    { name: "Bob", email: "bob@example.com" }
  ]) {
    id
    name
  }
}

# Update with where clause
mutation {
  updateUsers(
    where: { email: { eq: "alice@example.com" } }
    set: { name: "Alice Smith" }
  ) {
    id
    name
  }
}

# Delete with where clause
mutation {
  deleteUsers(where: { id: { eq: "uuid-here" } }) {
    id
    email
  }
}

Subscriptions

Real-time updates via WebSocket. Connect to ws://localhost:3000/api/graphql/ws using the graphql-transport-ws protocol.

GraphQL
# Subscribe to table changes
subscription {
  users {
    id
    name
    email
  }
}

# Subscribe to team changes
subscription {
  teams {
    id
    name
    slug
  }
}

# Subscribe to projects
subscription {
  projects {
    id
    name
    status
  }
}

Subscriptions are powered by PostgreSQL LISTEN/NOTIFY. Changes trigger automatically when data is inserted, updated, or deleted.

Filter Operators

OperatorDescription
eqEquals
neqNot equals
gt / gteGreater than / or equal
lt / lteLess than / or equal
like / ilikePattern match (case sensitive/insensitive)
inIn list of values
isNullIs null check

Example Request

cURL
curl -X POST http://localhost:3000/api/graphql \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer eyJhbGci..." \
  -d '{
    "query": "{ users { id name email } }"
  }'