fixed-api
This commit is contained in:
parent
92e5ec0b53
commit
6b53746c5f
|
@ -4,7 +4,6 @@ export default gql`
|
||||||
query GetChatsQuery {
|
query GetChatsQuery {
|
||||||
myChats {
|
myChats {
|
||||||
messages {
|
messages {
|
||||||
chatId
|
|
||||||
id
|
id
|
||||||
author
|
author
|
||||||
body
|
body
|
13
src/graphql/query/im-load-messages.ts
Normal file
13
src/graphql/query/im-load-messages.ts
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
import { gql } from '@urql/core'
|
||||||
|
|
||||||
|
export default gql`
|
||||||
|
query LoadMessagesQuery($chatId: String!, $offset: Int, $amount: Int) {
|
||||||
|
loadChat(chatId: $chatId, offset: $offset, amount: $amount) {
|
||||||
|
id
|
||||||
|
title
|
||||||
|
desc
|
||||||
|
slug
|
||||||
|
amount
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`
|
|
@ -31,17 +31,23 @@ export type Author = {
|
||||||
}
|
}
|
||||||
|
|
||||||
export type Chat = {
|
export type Chat = {
|
||||||
createdAt: Scalars['DateTime']
|
createdAt: Scalars['Int']
|
||||||
createdBy: User
|
createdBy: User
|
||||||
description?: Maybe<Scalars['String']>
|
description?: Maybe<Scalars['String']>
|
||||||
id: Scalars['Int']
|
id: Scalars['Int']
|
||||||
messages: Array<Maybe<Message>>
|
messages: Array<Maybe<Message>>
|
||||||
title?: Maybe<Scalars['String']>
|
title?: Maybe<Scalars['String']>
|
||||||
unread?: Maybe<Scalars['Int']>
|
unread?: Maybe<Scalars['Int']>
|
||||||
updatedAt: Scalars['DateTime']
|
updatedAt: Scalars['Int']
|
||||||
users: Array<Maybe<User>>
|
users: Array<Maybe<User>>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type ChatInput = {
|
||||||
|
description?: InputMaybe<Scalars['String']>
|
||||||
|
id: Scalars['String']
|
||||||
|
title?: InputMaybe<Scalars['String']>
|
||||||
|
}
|
||||||
|
|
||||||
export type ChatMember = {
|
export type ChatMember = {
|
||||||
invitedAt?: Maybe<Scalars['DateTime']>
|
invitedAt?: Maybe<Scalars['DateTime']>
|
||||||
invitedBy?: Maybe<Scalars['String']>
|
invitedBy?: Maybe<Scalars['String']>
|
||||||
|
@ -99,12 +105,11 @@ export enum FollowingEntity {
|
||||||
export type Message = {
|
export type Message = {
|
||||||
author: Scalars['String']
|
author: Scalars['String']
|
||||||
body: Scalars['String']
|
body: Scalars['String']
|
||||||
chatId: Scalars['Int']
|
chatId: Scalars['String']
|
||||||
createdAt: Scalars['DateTime']
|
createdAt: Scalars['Int']
|
||||||
id: Scalars['Int']
|
id: Scalars['Int']
|
||||||
replyTo?: Maybe<Scalars['Int']>
|
replyTo?: Maybe<Scalars['Int']>
|
||||||
updatedAt: Scalars['DateTime']
|
updatedAt?: Maybe<Scalars['Int']>
|
||||||
visibleForUsers?: Maybe<Array<Maybe<Scalars['Int']>>>
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum MessageStatus {
|
export enum MessageStatus {
|
||||||
|
@ -115,7 +120,7 @@ export enum MessageStatus {
|
||||||
|
|
||||||
export type Mutation = {
|
export type Mutation = {
|
||||||
confirmEmail: AuthResult
|
confirmEmail: AuthResult
|
||||||
createChat: Chat
|
createChat: Result
|
||||||
createCollection: Result
|
createCollection: Result
|
||||||
createCommunity: Result
|
createCommunity: Result
|
||||||
createMessage: Result
|
createMessage: Result
|
||||||
|
@ -128,6 +133,7 @@ export type Mutation = {
|
||||||
deleteReaction: Result
|
deleteReaction: Result
|
||||||
deleteShout: Result
|
deleteShout: Result
|
||||||
destroyTopic: Result
|
destroyTopic: Result
|
||||||
|
enterChat: Result
|
||||||
follow: Result
|
follow: Result
|
||||||
incrementView: Result
|
incrementView: Result
|
||||||
inviteAuthor: Result
|
inviteAuthor: Result
|
||||||
|
@ -139,6 +145,7 @@ export type Mutation = {
|
||||||
removeAuthor: Result
|
removeAuthor: Result
|
||||||
sendLink: Result
|
sendLink: Result
|
||||||
unfollow: Result
|
unfollow: Result
|
||||||
|
updateChat: Result
|
||||||
updateCollection: Result
|
updateCollection: Result
|
||||||
updateCommunity: Result
|
updateCommunity: Result
|
||||||
updateMessage: Result
|
updateMessage: Result
|
||||||
|
@ -153,7 +160,8 @@ export type MutationConfirmEmailArgs = {
|
||||||
}
|
}
|
||||||
|
|
||||||
export type MutationCreateChatArgs = {
|
export type MutationCreateChatArgs = {
|
||||||
description?: InputMaybe<Scalars['String']>
|
members: Array<InputMaybe<Scalars['String']>>
|
||||||
|
title?: InputMaybe<Scalars['String']>
|
||||||
}
|
}
|
||||||
|
|
||||||
export type MutationCreateCollectionArgs = {
|
export type MutationCreateCollectionArgs = {
|
||||||
|
@ -207,6 +215,10 @@ export type MutationDestroyTopicArgs = {
|
||||||
slug: Scalars['String']
|
slug: Scalars['String']
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type MutationEnterChatArgs = {
|
||||||
|
chatId: Scalars['String']
|
||||||
|
}
|
||||||
|
|
||||||
export type MutationFollowArgs = {
|
export type MutationFollowArgs = {
|
||||||
slug: Scalars['String']
|
slug: Scalars['String']
|
||||||
what: FollowingEntity
|
what: FollowingEntity
|
||||||
|
@ -257,6 +269,10 @@ export type MutationUnfollowArgs = {
|
||||||
what: FollowingEntity
|
what: FollowingEntity
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type MutationUpdateChatArgs = {
|
||||||
|
chat: ChatInput
|
||||||
|
}
|
||||||
|
|
||||||
export type MutationUpdateCollectionArgs = {
|
export type MutationUpdateCollectionArgs = {
|
||||||
collection: CollectionInput
|
collection: CollectionInput
|
||||||
}
|
}
|
||||||
|
@ -313,7 +329,6 @@ export type ProfileInput = {
|
||||||
export type Query = {
|
export type Query = {
|
||||||
authorsAll: Array<Maybe<User>>
|
authorsAll: Array<Maybe<User>>
|
||||||
collectionsAll: Array<Maybe<Collection>>
|
collectionsAll: Array<Maybe<Collection>>
|
||||||
enterChat: Chat
|
|
||||||
getCollabs: Array<Maybe<Collab>>
|
getCollabs: Array<Maybe<Collab>>
|
||||||
getCommunities: Array<Maybe<Community>>
|
getCommunities: Array<Maybe<Community>>
|
||||||
getCommunity: Community
|
getCommunity: Community
|
||||||
|
@ -356,10 +371,6 @@ export type Query = {
|
||||||
userReactedShouts: Array<Maybe<Shout>>
|
userReactedShouts: Array<Maybe<Shout>>
|
||||||
}
|
}
|
||||||
|
|
||||||
export type QueryEnterChatArgs = {
|
|
||||||
chatId: Scalars['String']
|
|
||||||
}
|
|
||||||
|
|
||||||
export type QueryGetCommunityArgs = {
|
export type QueryGetCommunityArgs = {
|
||||||
slug?: InputMaybe<Scalars['String']>
|
slug?: InputMaybe<Scalars['String']>
|
||||||
}
|
}
|
||||||
|
@ -385,9 +396,9 @@ export type QueryIsEmailUsedArgs = {
|
||||||
}
|
}
|
||||||
|
|
||||||
export type QueryLoadChatArgs = {
|
export type QueryLoadChatArgs = {
|
||||||
|
amount?: InputMaybe<Scalars['Int']>
|
||||||
chatId: Scalars['String']
|
chatId: Scalars['String']
|
||||||
page: Scalars['Int']
|
offset?: InputMaybe<Scalars['Int']>
|
||||||
size: Scalars['Int']
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export type QueryMarkdownBodyArgs = {
|
export type QueryMarkdownBodyArgs = {
|
||||||
|
@ -657,7 +668,7 @@ export type ShoutInput = {
|
||||||
topic_slugs?: InputMaybe<Array<InputMaybe<Scalars['String']>>>
|
topic_slugs?: InputMaybe<Array<InputMaybe<Scalars['String']>>>
|
||||||
versionOf?: InputMaybe<Scalars['String']>
|
versionOf?: InputMaybe<Scalars['String']>
|
||||||
visibleForRoles?: InputMaybe<Array<InputMaybe<Scalars['String']>>>
|
visibleForRoles?: InputMaybe<Array<InputMaybe<Scalars['String']>>>
|
||||||
visibleForUsers?: InputMaybe<Array<InputMaybe<Scalars['Int']>>>
|
visibleForUsers?: InputMaybe<Array<InputMaybe<Scalars['String']>>>
|
||||||
}
|
}
|
||||||
|
|
||||||
export type Stat = {
|
export type Stat = {
|
||||||
|
@ -669,15 +680,15 @@ export type Stat = {
|
||||||
}
|
}
|
||||||
|
|
||||||
export type Subscription = {
|
export type Subscription = {
|
||||||
chatUpdated: Result
|
newMessage: Message
|
||||||
onlineUpdated: Array<User>
|
onlineUpdated: Array<User>
|
||||||
reactionUpdated: ReactionUpdating
|
reactionUpdated: ReactionUpdating
|
||||||
shoutUpdated: Shout
|
shoutUpdated: Shout
|
||||||
userUpdated: User
|
userUpdated: User
|
||||||
}
|
}
|
||||||
|
|
||||||
export type SubscriptionChatUpdatedArgs = {
|
export type SubscriptionNewMessageArgs = {
|
||||||
chatId: Scalars['String']
|
chats?: InputMaybe<Array<Scalars['Int']>>
|
||||||
}
|
}
|
||||||
|
|
||||||
export type SubscriptionReactionUpdatedArgs = {
|
export type SubscriptionReactionUpdatedArgs = {
|
||||||
|
|
|
@ -4,7 +4,7 @@ import { Root } from '../components/Root'
|
||||||
import { apiClient } from '../utils/apiClient'
|
import { apiClient } from '../utils/apiClient'
|
||||||
import { initRouter } from '../stores/router'
|
import { initRouter } from '../stores/router'
|
||||||
|
|
||||||
const chatrooms = await apiClient.getInboxes()
|
const chatrooms = await apiClient.getChats()
|
||||||
|
|
||||||
const { pathname, search } = Astro.url
|
const { pathname, search } = Astro.url
|
||||||
initRouter(pathname, search)
|
initRouter(pathname, search)
|
||||||
|
|
|
@ -27,7 +27,8 @@ import reactionDestroy from '../graphql/mutation/reaction-destroy'
|
||||||
import reactionUpdate from '../graphql/mutation/reaction-update'
|
import reactionUpdate from '../graphql/mutation/reaction-update'
|
||||||
import authorsBySlugs from '../graphql/query/authors-by-slugs'
|
import authorsBySlugs from '../graphql/query/authors-by-slugs'
|
||||||
import incrementView from '../graphql/mutation/increment-view'
|
import incrementView from '../graphql/mutation/increment-view'
|
||||||
import myChats from '../graphql/query/my-chats'
|
import myChats from '../graphql/query/im-chats'
|
||||||
|
import loadChat from '../graphql/query/im-load-messages'
|
||||||
|
|
||||||
const FEED_SIZE = 50
|
const FEED_SIZE = 50
|
||||||
|
|
||||||
|
@ -325,8 +326,20 @@ export const apiClient = {
|
||||||
incrementView: async ({ articleSlug }) => {
|
incrementView: async ({ articleSlug }) => {
|
||||||
await privateGraphQLClient.mutation(incrementView, { shout: articleSlug })
|
await privateGraphQLClient.mutation(incrementView, { shout: articleSlug })
|
||||||
},
|
},
|
||||||
getInboxes: async (payload = {}) => {
|
getChats: async (payload = {}) => {
|
||||||
const resp = await privateGraphQLClient.query(myChats, payload).toPromise()
|
const resp = await privateGraphQLClient.query(myChats, payload).toPromise()
|
||||||
return resp.data.myChats
|
return resp.data.myChats
|
||||||
|
},
|
||||||
|
getChatMessages: async ({
|
||||||
|
chatId,
|
||||||
|
offset = 0,
|
||||||
|
amount = 50
|
||||||
|
}: {
|
||||||
|
chatId: string
|
||||||
|
offset?: number
|
||||||
|
amount?: number
|
||||||
|
}) => {
|
||||||
|
const resp = await privateGraphQLClient.query(loadChat, { chatId, offset, amount }).toPromise()
|
||||||
|
return resp.data.loadChat
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user