GraphQL API

GraphQL endpoint, GraphQL queries, GraphQL mutations, GraphQL schema, GraphQL examples.

GraphQL API

The GraphQL API provides a flexible, type-safe interface for querying and mutating data. Use GraphQL when you need to fetch multiple related resources in a single request or when you want to specify exactly which fields to retrieve.

GraphQL Endpoint

Endpoint:

POST https://api.example.com/graphql

Request Format:

POST /graphql HTTP/1.1
Host: api.example.com
Authorization: Bearer your_access_token
Content-Type: application/json

{
  "query": "query { recordings { id title } }"
}

GraphQL Queries

Query data using GraphQL:

Simple Query:

query {
  recordings {
    id
    title
    duration
    created_at
  }
}

Query with Variables:

query GetRecording($id: ID!) {
  recording(id: $id) {
    id
    title
    transcript {
      text
      speakers {
        name
      }
    }
  }
}

Variables:

{
  "id": "123"
}

Query with Filters:

query {
  recordings(
    first: 10
    page: 1
    filter: {
      status: "completed"
      folder_id: 456
    }
  ) {
    data {
      id
      title
    }
    paginatorInfo {
      total
      currentPage
      hasMorePages
    }
  }
}

GraphQL Mutations

Modify data using GraphQL mutations:

Create Recording:

mutation CreateRecording($input: CreateRecordingInput!) {
  createRecording(input: $input) {
    id
    title
    status
  }
}

Variables:

{
  "input": {
    "title": "Team Meeting",
    "description": "Weekly team sync",
    "folder_id": 123
  }
}

Update Recording:

mutation UpdateRecording($id: ID!, $input: UpdateRecordingInput!) {
  updateRecording(id: $id, input: $input) {
    id
    title
    updated_at
  }
}

Delete Recording:

mutation DeleteRecording($id: ID!) {
  deleteRecording(id: $id) {
    success
    message
  }
}

GraphQL Schema

Explore the GraphQL schema:

  • Schema Introspection: Query the schema to discover available types and fields
  • Type System: Strong typing ensures data consistency
  • Documentation: Schema includes descriptions for all types and fields
  • Validation: Queries are validated before execution

Introspection Query:

query IntrospectionQuery {
  __schema {
    types {
      name
      description
      fields {
        name
        type {
          name
        }
      }
    }
  }
}

Use GraphQL playground or tools like GraphiQL to explore the schema interactively.

GraphQL Examples

Fetch Recordings with Transcripts:

query {
  recordings(first: 5) {
    data {
      id
      title
      transcript {
        text
        speakers {
          id
          name
        }
      }
      summary {
        text
        actionItems {
          text
          assignee
        }
      }
    }
  }
}

Batch Query Multiple Resources:

query {
  recordings: recordings(first: 10) {
    data { id title }
  }
  meetings: meetings(first: 10) {
    data { id title }
  }
  folders: folders {
    data { id name }
  }
}

Complex Nested Query:

query {
  recording(id: "123") {
    id
    title
    meeting {
      id
      title
      attendees {
        name
        email
      }
    }
    transcript {
      segments {
        start_time
        end_time
        text
        speaker {
          id
          name
        }
      }
    }
    signals {
      type
      domain
      text
      confidence
    }
  }
}