API Reference

Chat

Manage local chat messages, channels, and paired peers. All GraphQL operations are sent to POST /graphql.

Type Definitions

bash
type ChatItem {
  id: ID!
  fromId: String!      # "me" | peerId
  toId: String!        # peerId (direct) | "" (channel)
  channelId: String!   # "" for direct messages
  content: String!     # JSON-encoded message payload
  createdAt: String!   # ISO 8601
  updatedAt: String!
  status: String!      # "sent" | "pending" | "failed"
  statusData: String!  # extra info on failure
}

type ChatChannel {
  id: String!
  name: String!
  owner: String!             # "me" | peerId
  members: [ChatChannelMember!]!
  version: Int!
  status: String!            # "active" | "left"
  createdAt: String!
  updatedAt: String!
}

type ChatChannelMember {
  id: String!
  status: String!            # "active" | "pending"
}

type Peer {
  id: String!
  name: String!
  ip: String!
  status: String!            # "online" | "offline"
  port: Int!
  deviceType: String!        # "phone" | "tablet" | "pc"
  createdAt: String!
  updatedAt: String!
}

type AppFile {
  id: ID!
  size: Int!                 # bytes
  mimeType: String!
  realPath: String!
  fileName: String!
  createdAt: String!
  updatedAt: String!
}

Operations

query

chatItems

Get all messages in a conversation. Prefix the id with "channel:" or "peer:".

bash
query GetChatItems($id: String!) {
  chatItems(id: $id) {
    id fromId toId channelId
    content createdAt updatedAt status statusData
  }
}
query

latestChatItems

Get the latest message from every conversation (channels + peers). Useful for building a conversation list preview.

bash
query GetLatestChatItems {
  latestChatItems {
    id fromId toId channelId content createdAt updatedAt status
  }
}
query

chatChannels

List all chat channels owned or joined by the device.

bash
query GetChatChannels {
  chatChannels {
    id name owner version status createdAt updatedAt
    members { id status }
  }
}
query

peers

List all known peers that have paired with this device.

bash
query GetPeers {
  peers { id name ip status port deviceType createdAt updatedAt }
}
mutation

deletePeer

Delete a peer record from this device. Does not unpair on the remote side; use unpairPeer for a clean two-sided unpair.

bash
mutation DeletePeer($id: ID!) {
  deletePeer(id: $id)
}
mutation

unpairPeer

Unpair a peer device. Clears pairing state on this device and signals the remote peer when reachable.

bash
mutation UnpairPeer($id: ID!) {
  unpairPeer(id: $id)
}
query

appFiles

Paginated list of files shared through chat.

bash
query GetAppFiles($offset: Int!, $limit: Int!) {
  appFiles(offset: $offset, limit: $limit) {
    id size mimeType realPath fileName createdAt updatedAt
  }
}
query

appFileCount

Total count of files shared via chat.

bash
query GetAppFileCount {
  appFileCount
}
mutation

sendChatItem

Send a message to a channel or peer. toId format: "channel:<id>" or "peer:<id>".

bash
mutation SendChatItem($toId: String!, $content: String!) {
  sendChatItem(toId: $toId, content: $content) {
    id fromId toId channelId content createdAt updatedAt status
  }
}
mutation

deleteChatItem

Delete a chat message by ID.

bash
mutation DeleteChatItem($id: ID!) {
  deleteChatItem(id: $id)
}
mutation

deleteChatItems

Bulk-delete chat messages matching a query (e.g. "id:msg_x,id:msg_y").

bash
mutation DeleteChatItems($query: String!) {
  deleteChatItems(query: $query)
}
mutation

retryChatItem

Retry sending a failed message.

bash
mutation RetryChatItem($id: ID!) {
  retryChatItem(id: $id) { id status }
}
mutation

createChatChannel

Create a new encrypted channel owned by this device.

bash
mutation CreateChatChannel($name: String!) {
  createChatChannel(name: $name) {
    id name owner version status createdAt
  }
}
mutation

updateChatChannel

Rename a chat channel.

bash
mutation UpdateChatChannel($id: ID!, $name: String!) {
  updateChatChannel(id: $id, name: $name) { id name version updatedAt }
}
mutation

deleteChatChannel

Delete a channel and all its messages.

bash
mutation DeleteChatChannel($id: ID!) {
  deleteChatChannel(id: $id)
}
mutation

leaveChatChannel

Leave a channel you do not own.

bash
mutation LeaveChatChannel($id: ID!) {
  leaveChatChannel(id: $id)
}
mutation

addChatChannelMember

Invite a peer into a channel you own.

bash
mutation AddMember($id: ID!, $peerId: String!) {
  addChatChannelMember(id: $id, peerId: $peerId) {
    id members { id status }
  }
}
mutation

removeChatChannelMember

Remove a member from a channel you own.

bash
mutation RemoveMember($id: ID!, $peerId: String!) {
  removeChatChannelMember(id: $id, peerId: $peerId) {
    id members { id status }
  }
}
mutation

acceptChatChannelInvite

Accept an invitation to join a channel you were invited to.

bash
mutation AcceptChatChannelInvite($id: ID!) {
  acceptChatChannelInvite(id: $id)
}
mutation

declineChatChannelInvite

Decline a pending channel invitation.

bash
mutation DeclineChatChannelInvite($id: ID!) {
  declineChatChannelInvite(id: $id)
}