Files
api/web/components/Notifications/graphql/notification.query.ts
Eli Bosley 586653ccc1 chore: add a prefix scalar instead of prefix plugin (#1361)
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
- Introduced a new `PrefixedID` scalar type for all GraphQL IDs,
ensuring unique identifiers across multiple servers by prefixing IDs
with a server identifier.
- Added detailed documentation for the `PrefixedID` scalar in the API
schema.
- Grouped VM and parity check mutations under dedicated fields for
better organization.
- Added new scalar `Port` and input type `AccessUrlInput` for improved
type safety.

- **Refactor**
- Replaced all usages of standard `ID` or `String` with `PrefixedID` for
IDs in queries, mutations, and models.
- Consolidated ID handling by extending a common `Node` base class
across models, removing redundant `id` declarations.
- Updated GraphQL argument types and resolver signatures to explicitly
use `PrefixedID`.
- Updated GraphQL code generation to map `PrefixedID` to TypeScript
`string`.

- **Bug Fixes**
- Enhanced test assertions to verify API key creation timestamps are
strings.
  - Fixed internal property naming for registration ID.

- **Chores**
- Removed legacy ID prefix Apollo Server plugin in favor of the new
scalar approach.
  - Cleaned up imports and unused fields related to ID handling.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
2025-04-29 12:22:18 -04:00

116 lines
2.1 KiB
TypeScript

import { graphql } from '~/composables/gql/gql';
export const NOTIFICATION_FRAGMENT = graphql(/* GraphQL */ `
fragment NotificationFragment on Notification {
id
title
subject
description
importance
link
type
timestamp
formattedTimestamp
}
`);
export const NOTIFICATION_COUNT_FRAGMENT = graphql(/* GraphQL */ `
fragment NotificationCountFragment on NotificationCounts {
total
info
warning
alert
}
`);
export const getNotifications = graphql(/* GraphQL */ `
query Notifications($filter: NotificationFilter!) {
notifications {
id
list(filter: $filter) {
...NotificationFragment
}
}
}
`);
export const archiveNotification = graphql(/* GraphQL */ `
mutation ArchiveNotification($id: PrefixedID!) {
archiveNotification(id: $id) {
...NotificationFragment
}
}
`);
export const archiveAllNotifications = graphql(/* GraphQL */ `
mutation ArchiveAllNotifications {
archiveAll {
unread {
total
}
archive {
info
warning
alert
total
}
}
}
`);
export const deleteNotification = graphql(/* GraphQL */ `
mutation DeleteNotification($id: PrefixedID!, $type: NotificationType!) {
deleteNotification(id: $id, type: $type) {
archive {
total
}
}
}
`);
export const deleteArchivedNotifications = graphql(/* GraphQL */ `
mutation DeleteAllNotifications {
deleteArchivedNotifications {
archive {
total
}
unread {
total
}
}
}
`);
export const notificationsOverview = graphql(/* GraphQL */ `
query Overview {
notifications {
id
overview {
unread {
info
warning
alert
total
}
archive {
total
}
}
}
}
`);
/** Re-calculates the notifications overview (i.e. notification counts) */
export const resetOverview = graphql(/* GraphQL */ `
mutation RecomputeOverview {
recalculateOverview {
archive {
...NotificationCountFragment
}
unread {
...NotificationCountFragment
}
}
}
`);