add-gql
This commit is contained in:
parent
4f7702a77f
commit
de097240e3
10
src/graphql/mutation/chat-delete.ts
Normal file
10
src/graphql/mutation/chat-delete.ts
Normal file
|
@ -0,0 +1,10 @@
|
|||
import { ChatInput } from './../types.gen'
|
||||
import { gql } from '@urql/core'
|
||||
|
||||
export default gql`
|
||||
mutation DeleteChat($chat_id: String!) {
|
||||
deleteChat(chat_id: $chat_id) {
|
||||
error
|
||||
}
|
||||
}
|
||||
`
|
17
src/graphql/mutation/chat-message-create.ts
Normal file
17
src/graphql/mutation/chat-message-create.ts
Normal file
|
@ -0,0 +1,17 @@
|
|||
import { gql } from '@urql/core'
|
||||
|
||||
export default gql`
|
||||
mutation createMessage($chat: String!, $body: String!, $reply_to: Int) {
|
||||
createMessage(chat: $chat, body: $body, reply_to: $reply_to) {
|
||||
error
|
||||
message {
|
||||
id
|
||||
body
|
||||
author
|
||||
created_at
|
||||
reply_to
|
||||
updated_at
|
||||
}
|
||||
}
|
||||
}
|
||||
`
|
9
src/graphql/mutation/chat-message-delete.ts
Normal file
9
src/graphql/mutation/chat-message-delete.ts
Normal file
|
@ -0,0 +1,9 @@
|
|||
import { gql } from '@urql/core'
|
||||
|
||||
export default gql`
|
||||
mutation DeleteMessage($chat_id: String!) {
|
||||
deleteMessage(chat_id: $chat_id) {
|
||||
error
|
||||
}
|
||||
}
|
||||
`
|
|
@ -1,8 +1,9 @@
|
|||
import { ChatInput } from './../types.gen'
|
||||
import { gql } from '@urql/core'
|
||||
|
||||
export default gql`
|
||||
mutation createMessage($chat: String!, $body: String!, $replyTo: Int) {
|
||||
createMessage(chat: $chat, body: $body, replyTo: $replyTo) {
|
||||
mutation UpdateMessage($message: MessageInput!) {
|
||||
createMessage(message: $message) {
|
||||
error
|
||||
message {
|
||||
id
|
17
src/graphql/mutation/chat-update.ts
Normal file
17
src/graphql/mutation/chat-update.ts
Normal file
|
@ -0,0 +1,17 @@
|
|||
import { ChatInput } from './../types.gen'
|
||||
import { gql } from '@urql/core'
|
||||
|
||||
export default gql`
|
||||
mutation UpdateChat($chat: ChatInput!) {
|
||||
updateChat(chat: $chat) {
|
||||
error
|
||||
chat {
|
||||
id
|
||||
members {
|
||||
id
|
||||
slug
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`
|
|
@ -8,7 +8,6 @@ export default gql`
|
|||
id
|
||||
title
|
||||
admins
|
||||
users
|
||||
members {
|
||||
id
|
||||
slug
|
||||
|
@ -17,7 +16,7 @@ export default gql`
|
|||
}
|
||||
unread
|
||||
description
|
||||
updatedAt
|
||||
updated_at
|
||||
private
|
||||
messages {
|
||||
id
|
||||
|
|
|
@ -18,7 +18,12 @@ import type {
|
|||
Shout,
|
||||
NotificationsQueryParams,
|
||||
NotificationsQueryResult,
|
||||
MySubscriptionsQueryResult
|
||||
MySubscriptionsQueryResult,
|
||||
MutationUpdateMessageArgs,
|
||||
MutationDeleteMessageArgs,
|
||||
MutationMarkAsReadArgs,
|
||||
MutationDeleteChatArgs,
|
||||
MutationUpdateChatArgs
|
||||
} from '../graphql/types.gen'
|
||||
import { publicGraphQLClient } from '../graphql/publicGraphQLClient'
|
||||
import { getToken, privateGraphQLClient, privateInboxGraphQLClient } from '../graphql/privateGraphQLClient'
|
||||
|
@ -45,7 +50,6 @@ import userSubscribers from '../graphql/query/author-followers'
|
|||
import userFollowedAuthors from '../graphql/query/author-following-users'
|
||||
import userFollowedTopics from '../graphql/query/author-following-topics'
|
||||
import topicBySlug from '../graphql/query/topic-by-slug'
|
||||
import createChat from '../graphql/mutation/create-chat'
|
||||
import reactionsLoadBy from '../graphql/query/reactions-load-by'
|
||||
import authorsLoadBy from '../graphql/query/authors-load-by'
|
||||
import shoutsLoadBy from '../graphql/query/articles-load-by'
|
||||
|
@ -53,13 +57,19 @@ import draftsLoad from '../graphql/query/drafts-load'
|
|||
import shoutLoad from '../graphql/query/article-load'
|
||||
import myFeed from '../graphql/query/my-feed'
|
||||
import loadRecipients from '../graphql/query/chat-recipients'
|
||||
import createMessage from '../graphql/mutation/create-chat-message'
|
||||
import updateProfile from '../graphql/mutation/update-profile'
|
||||
import updateArticle from '../graphql/mutation/article-update'
|
||||
import deleteShout from '../graphql/mutation/article-delete'
|
||||
// import notifications from '../graphql/query/notifications'
|
||||
// import markNotificationAsRead from '../graphql/mutation/mark-notification-as-read'
|
||||
import markAllNotificationsAsRead from '../graphql/mutation/mark-all-notifications-as-read'
|
||||
import markAsRead from '../graphql/mutation/chat-mark-as-read'
|
||||
import createChat from '../graphql/mutation/chat-create'
|
||||
import updateChat from '../graphql/mutation/chat-update'
|
||||
import deleteChat from '../graphql/mutation/chat-delete'
|
||||
import createChatMessage from '../graphql/mutation/chat-message-create'
|
||||
import updateChatMessage from '../graphql/mutation/chat-message-update'
|
||||
import deleteChatMessage from '../graphql/mutation/chat-message-delete'
|
||||
import mySubscriptions from '../graphql/query/my-subscriptions'
|
||||
|
||||
type ApiErrorCode =
|
||||
|
@ -391,11 +401,36 @@ export const inboxClient = {
|
|||
return resp.data.createChat
|
||||
},
|
||||
|
||||
markAsRead: async (options: MutationMarkAsReadArgs) => {
|
||||
const resp = await privateInboxGraphQLClient.mutation(markAsRead, options).toPromise()
|
||||
return resp.data.markAsRead
|
||||
},
|
||||
|
||||
updateChat: async (options: MutationUpdateChatArgs) => {
|
||||
const resp = await privateInboxGraphQLClient.mutation(updateChat, options).toPromise()
|
||||
return resp.data.updateChat
|
||||
},
|
||||
|
||||
deleteChat: async (options: MutationDeleteChatArgs) => {
|
||||
const resp = await privateInboxGraphQLClient.mutation(deleteChat, options).toPromise()
|
||||
return resp.data.deleteChat
|
||||
},
|
||||
|
||||
createMessage: async (options: MutationCreateMessageArgs) => {
|
||||
const resp = await privateInboxGraphQLClient.mutation(createMessage, options).toPromise()
|
||||
const resp = await privateInboxGraphQLClient.mutation(createChatMessage, options).toPromise()
|
||||
return resp.data.createMessage.message
|
||||
},
|
||||
|
||||
updateMessage: async (options: MutationUpdateMessageArgs) => {
|
||||
const resp = await privateInboxGraphQLClient.mutation(updateChatMessage, options).toPromise()
|
||||
return resp.data.updateMessage.message
|
||||
},
|
||||
|
||||
deleteMessage: async (options: MutationDeleteMessageArgs) => {
|
||||
const resp = await privateInboxGraphQLClient.mutation(deleteChatMessage, options).toPromise()
|
||||
return resp.data.deleteMessage
|
||||
},
|
||||
|
||||
loadChatMessages: async (options: QueryLoadMessagesByArgs) => {
|
||||
const resp = await privateInboxGraphQLClient.query(chatMessagesLoadBy, options).toPromise()
|
||||
return resp.data.loadMessagesBy.messages
|
||||
|
|
Loading…
Reference in New Issue
Block a user