Chat
Centralized chat service for personal, group and in-game chats.
Introduction
Welcome to the official chat system documentation. This guide delineates the structured procedures to interact with the chat service through GraphQL. Clear examples for each function are provided for precise understanding.
Retrieving Chats
To systematically query all associated chat sessions, use the following:
query GetChats {
chats {
__typename
... on ChatsOk {
result {
id
users {
id
}
lastMessage {
message
}
}
}
... on Error {
message
}
}
}Accessing Messages Within a Chat
For accessing the messages within a specified chat, use:
query GetMessages($chatId: ID!) {
messages(chatId: $chatId) {
__typename
... on MessagesOk {
result {
message
author {
id
}
}
}
... on Error {
message
}
}
}Variables:
{
"chatId": "YourChatID"
}Initiating a New Chat Session
To systematically initiate a new chat session:
mutation CreateChat($user1: String!, $user2: String!) {
createChat(users: [$user1, $user2]) {
__typename
... on CreateChatOk {
result
}
... on Error {
message
}
}
}Variables:
{
"user1": "User1ID",
"user2": "User2ID"
}Transmitting a Message
For transmitting a message within a chat:
mutation SendMessage($chatId: ID!, $content: String!) {
sendMessage(chatId: $chatId, message: $content) {
__typename
... on SendMessageOk {
result
}
... on Error {
message
}
}
}Variables:
{
"chatId": "YourChatID",
"content": "YourMessageContent"
}Deletion of a Message
To systematically retract a message:
mutation DeleteMessage($chatId: ID!, $messageId: ID!) {
deleteMessage(chatId: $chatId, id: $messageId) {
__typename
... on DeleteMessageOk {
result
}
... on Error {
message
}
}
}Variables:
{
"chatId": "YourChatID",
"messageId": "YourMessageID"
}Real-time Message Update Subscription
As of 22th August 2023, subscription is not working correctly in stitched services (api.bine.games). Currently as a workaround, api.bine.games/chat is routing for chat service exclusively. Subscription is working there, but it does not allow for all fields to be queried (like nickname).
For users necessitating real-time updates:
subscription OnMessageChange($chatId: ID!) {
messages(chatId: $chatId) {
mutationType
id
chatId
message {
message
author {
id
}
}
}
}Variables:
{
"chatId": "YourChatID"
}Your adherence to this structured approach is highly esteemed. For further clarifications, kindly refer to the overarching documentation.
Last updated