webapp/src/graphql/client/notifier.ts

26 lines
1.1 KiB
TypeScript
Raw Normal View History

2023-11-28 13:18:25 +00:00
import markAllNotificationsAsRead from '../mutation/notifier/mark-all-notifications-as-read'
import markNotificationAsRead from '../mutation/notifier/mark-notification-as-read'
import { getPrivateClient } from '../privateGraphQLClient'
import loadNotifications from '../query/notifier/notifications-load'
2023-11-28 18:04:51 +00:00
import { NotificationsResult, QueryLoad_NotificationsArgs } from '../schema/notifier.gen'
2023-11-28 13:18:25 +00:00
export const notifierPrivateGraphqlClient = getPrivateClient('notifier')
export const notifierClient = {
getNotifications: async (params: QueryLoad_NotificationsArgs): Promise<NotificationsResult> => {
2023-11-28 15:36:00 +00:00
const resp = await notifierPrivateGraphqlClient.query(loadNotifications, params).toPromise()
2023-11-28 13:18:25 +00:00
return resp.data.load_notifications
},
markNotificationAsRead: async (notification_id: number): Promise<void> => {
await notifierPrivateGraphqlClient
.mutation(markNotificationAsRead, {
notification_id,
})
.toPromise()
},
markAllNotificationsAsRead: async (): Promise<void> => {
await notifierPrivateGraphqlClient.mutation(markAllNotificationsAsRead, {}).toPromise()
},
}