API リファレンス

Chat

ローカルのチャットメッセージ、チャンネル、ペアリングされた peers を管理します。すべての GraphQL 操作は POST /graphql に送信されます。

型定義

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!
  ownerId: ID!             # "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!
}

操作

query

chatItems

会話内のすべてのメッセージを取得します。id の先頭に "channel:" または "peer:" を付けてください。

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

latestChatItems

すべての会話 (チャンネル + peers) の最新メッセージを取得します。会話リストのプレビューを構築するのに便利です。

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

chatChannels

このデバイスが所有または参加しているすべてのチャットチャンネルを一覧表示します。

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

peers

このデバイスとペアリングされた既知の peers をすべて一覧表示します。

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

deletePeer

このデバイスから peer レコードを削除します。リモート側ではペアリング解除されません。クリーンな双方向ペアリング解除には unpairPeer を使用してください。

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

unpairPeer

peer デバイスのペアリングを解除します。このデバイスのペアリング状態をクリアし、到達可能な場合はリモート peer にシグナルを送ります。

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

appFiles

チャット経由で共有されたファイルのページ分割されたリスト。

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

appFileCount

チャット経由で共有されたファイルの合計数。

bash
query GetAppFileCount {
  appFileCount
}
mutation

sendChatItem

チャンネルまたは peer にメッセージを送信します。toId 形式:"channel:<id>" または "peer:<id>"。

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

deleteChatItem

ID でチャットメッセージを削除します。

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

deleteChatItems

クエリに一致するチャットメッセージを一括削除します (例: "id:msg_x,id:msg_y")。

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

retryChatItem

失敗したメッセージの送信を再試行します。

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

createChatChannel

このデバイスが所有する新しい暗号化チャンネルを作成します。

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

updateChatChannel

チャットチャンネルの名前を変更します。

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

deleteChatChannel

チャンネルとそのすべてのメッセージを削除します。

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

leaveChatChannel

所有していないチャンネルから退出します。

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

addChatChannelMember

自分が所有するチャンネルに peer を招待します。

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

removeChatChannelMember

自分が所有するチャンネルからメンバーを削除します。

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

acceptChatChannelInvite

招待されたチャンネルへの参加招待を承諾します。

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

declineChatChannelInvite

保留中のチャンネル招待を辞退します。

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