Chat
Manage local chat messages, channels, and paired peers. All GraphQL operations are sent to POST /graphql.
Type Definitions
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
chatItems
Get all messages in a conversation. Prefix the id with "channel:" or "peer:".
query GetChatItems($id: String!) {
chatItems(id: $id) {
id fromId toId channelId
content createdAt updatedAt status statusData
}
}latestChatItems
Get the latest message from every conversation (channels + peers). Useful for building a conversation list preview.
query GetLatestChatItems {
latestChatItems {
id fromId toId channelId content createdAt updatedAt status
}
}chatChannels
List all chat channels owned or joined by the device.
query GetChatChannels {
chatChannels {
id name owner version status createdAt updatedAt
members { id status }
}
}peers
List all known peers that have paired with this device.
query GetPeers {
peers { id name ip status port deviceType createdAt updatedAt }
}deletePeer
Delete a peer record from this device. Does not unpair on the remote side; use unpairPeer for a clean two-sided unpair.
mutation DeletePeer($id: ID!) {
deletePeer(id: $id)
}unpairPeer
Unpair a peer device. Clears pairing state on this device and signals the remote peer when reachable.
mutation UnpairPeer($id: ID!) {
unpairPeer(id: $id)
}appFiles
Paginated list of files shared through chat.
query GetAppFiles($offset: Int!, $limit: Int!) {
appFiles(offset: $offset, limit: $limit) {
id size mimeType realPath fileName createdAt updatedAt
}
}appFileCount
Total count of files shared via chat.
query GetAppFileCount {
appFileCount
}sendChatItem
Send a message to a channel or peer. toId format: "channel:<id>" or "peer:<id>".
mutation SendChatItem($toId: String!, $content: String!) {
sendChatItem(toId: $toId, content: $content) {
id fromId toId channelId content createdAt updatedAt status
}
}deleteChatItem
Delete a chat message by ID.
mutation DeleteChatItem($id: ID!) {
deleteChatItem(id: $id)
}deleteChatItems
Bulk-delete chat messages matching a query (e.g. "id:msg_x,id:msg_y").
mutation DeleteChatItems($query: String!) {
deleteChatItems(query: $query)
}retryChatItem
Retry sending a failed message.
mutation RetryChatItem($id: ID!) {
retryChatItem(id: $id) { id status }
}createChatChannel
Create a new encrypted channel owned by this device.
mutation CreateChatChannel($name: String!) {
createChatChannel(name: $name) {
id name owner version status createdAt
}
}updateChatChannel
Rename a chat channel.
mutation UpdateChatChannel($id: ID!, $name: String!) {
updateChatChannel(id: $id, name: $name) { id name version updatedAt }
}deleteChatChannel
Delete a channel and all its messages.
mutation DeleteChatChannel($id: ID!) {
deleteChatChannel(id: $id)
}leaveChatChannel
Leave a channel you do not own.
mutation LeaveChatChannel($id: ID!) {
leaveChatChannel(id: $id)
}addChatChannelMember
Invite a peer into a channel you own.
mutation AddMember($id: ID!, $peerId: String!) {
addChatChannelMember(id: $id, peerId: $peerId) {
id members { id status }
}
}removeChatChannelMember
Remove a member from a channel you own.
mutation RemoveMember($id: ID!, $peerId: String!) {
removeChatChannelMember(id: $id, peerId: $peerId) {
id members { id status }
}
}acceptChatChannelInvite
Accept an invitation to join a channel you were invited to.
mutation AcceptChatChannelInvite($id: ID!) {
acceptChatChannelInvite(id: $id)
}declineChatChannelInvite
Decline a pending channel invitation.
mutation DeclineChatChannelInvite($id: ID!) {
declineChatChannelInvite(id: $id)
}