"""Single source of truth for Web (Apollo) and Android (Apollo Kotlin).""" scalar DateTime enum MessageKind { TEXT MEDIA SYSTEM } enum ChatType { DIRECT GROUP CHANNEL } enum MemberRole { OWNER ADMIN MEMBER SUBSCRIBER } enum ChatEventType { MESSAGE_CREATED MESSAGE_UPDATED MESSAGE_DELETED TYPING PRESENCE READ_RECEIPT DELIVERED } enum AccountEventType { DEVICE_ADDED DEVICE_REVOKED SESSION_REFRESHED } type User { id: ID! displayName: String! email: String createdAt: DateTime! } type Device { id: ID! userId: ID! name: String lastSeenAt: DateTime createdAt: DateTime! } type AuthPayload { accessToken: String! refreshToken: String! user: User! } type MediaRef { id: ID! mimeType: String! url: String! thumbnailUrl: String } type Message { id: ID! chatId: ID! senderId: ID sender: User kind: MessageKind! body: String mediaRefs: [MediaRef!]! replyToId: ID seq: Int! createdAt: DateTime! editedAt: DateTime deletedAt: DateTime } type MessageEdge { cursor: String! node: Message! } type MessageConnection { edges: [MessageEdge!]! pageInfo: PageInfo! } type PageInfo { endCursor: String hasNextPage: Boolean! } interface ChatBase { id: ID! type: ChatType! title: String lastMessage: Message unreadCount: Int! updatedAt: DateTime! } type DirectThread implements ChatBase { id: ID! type: ChatType! title: String peer: User! lastMessage: Message unreadCount: Int! updatedAt: DateTime! } type Group implements ChatBase { id: ID! type: ChatType! title: String lastMessage: Message unreadCount: Int! updatedAt: DateTime! memberCount: Int! isBroadcast: Boolean! } type Channel implements ChatBase { id: ID! type: ChatType! title: String lastMessage: Message unreadCount: Int! updatedAt: DateTime! subscriberCount: Int! pinnedMessages: [Message!]! } union Chat = DirectThread | Group | Channel type PresignedUpload { uploadUrl: String! mediaId: ID! headers: [HttpHeader!] } type HttpHeader { name: String! value: String! } input HttpHeaderInput { name: String! value: String! } type CallSession { id: ID! chatId: ID! createdBy: ID! status: CallStatus! iceServers: [IceServer!]! createdAt: DateTime! } enum CallStatus { RINGING ACTIVE ENDED } type IceServer { urls: [String!]! username: String credential: String } type Bot { id: ID! displayName: String! tokenHint: String! webhookUrl: String createdAt: DateTime! } type Query { me: User myDevices: [Device!]! chats: [Chat!]! messages(chatId: ID!, after: String, first: Int = 30): MessageConnection! bot(id: ID!): Bot myBots: [Bot!]! } type Mutation { register(email: String!, password: String!, displayName: String!): AuthPayload! login(email: String!, password: String!): AuthPayload! refresh(refreshToken: String!): AuthPayload! registerDevice(name: String): Device! revokeDevice(deviceId: ID!): Boolean! createDirectThread(peerUserId: ID!): DirectThread! createGroup(title: String!, memberIds: [ID!], isBroadcast: Boolean = false): Group! createChannel(title: String!, isPublic: Boolean = false): Channel! joinChannel(channelId: ID!): Boolean! inviteToGroup(groupId: ID!, userIds: [ID!]!): Boolean! setMemberRole(chatId: ID!, userId: ID!, role: MemberRole!): Boolean! pinMessage(chatId: ID!, messageId: ID!): Boolean! unpinMessage(chatId: ID!, messageId: ID!): Boolean! sendMessage(chatId: ID!, body: String, replyToId: ID): Message! editMessage(messageId: ID!, body: String!): Message! deleteMessage(messageId: ID!, forEveryone: Boolean = false): Boolean! markDelivered(chatId: ID!, upToSeq: Int!): Boolean! markRead(chatId: ID!, upToSeq: Int!): Boolean! setTyping(chatId: ID!, isTyping: Boolean!): Boolean! requestMediaUpload(mimeType: String!, bytesHint: Int): PresignedUpload! finalizeMediaUpload(mediaId: ID!, mimeType: String!, sizeBytes: Int!): MediaRef! sendMediaMessage(chatId: ID!, mediaId: ID!, caption: String, replyToId: ID): Message! startCall(chatId: ID!): CallSession! endCall(callId: ID!): Boolean! createBot(displayName: String!, webhookUrl: String): BotTokenPayload! rotateBotToken(botId: ID!): BotTokenPayload! setBotWebhook(botId: ID!, webhookUrl: String): Boolean! addBotToChat(chatId: ID!, botId: ID!): Boolean! } type BotTokenPayload { bot: Bot! token: String! } type ChatEvent { type: ChatEventType! chatId: ID! message: Message userId: ID isTyping: Boolean online: Boolean upToSeq: Int at: DateTime! } type AccountEvent { type: AccountEventType! deviceId: ID at: DateTime! } type Subscription { onChatEvent(chatId: ID!): ChatEvent! onAccountEvent: AccountEvent! }