PlainApp
API 参考

通知

通过 app.capabilities 判断功能支持,通过 app.access 和宿主权限判断访问授权。示例使用合成数据,调用前请替换路径、ID、输入和筛选条件。

类型定义

graphql
type Subscription {
  notificationCreated: Notification!
  notificationUpdated: Notification!
  notificationDeleted: Notification!
  notificationRefreshed: Boolean!
}

type Mutation {
  deleteNotifications(ids: [ID!]!): ActionResult!
  replyNotification(id: ID!, actionIndex: Int!, text: String!): Boolean!
}

type Query {
  notificationCount(query: String!): Int!
  notifications(query: String!, offset: Int!, limit: Int!): [Notification!]!
}

type ActionResult {
	affectedCount: Int!
}

scalar Instant

type Notification {
	id: ID!
	
	onlyOnce: Boolean!
	isClearable: Boolean!
	appId: ID!
	appName: String!
	postedAt: Instant!
	silent: Boolean!
	title: String!
	body: String!
	actions: [String!]!
	
	replyActions: [String!]!
}

操作

subscription

notificationCreated

接收新观察到的设备通知。

graphql
subscription notificationCreated {
  notificationCreated { id onlyOnce isClearable appId appName postedAt silent title }
}
subscription

notificationUpdated

接收已更新的设备通知。

graphql
subscription notificationUpdated {
  notificationUpdated { id onlyOnce isClearable appId appName postedAt silent title }
}
subscription

notificationDeleted

接收已移除的设备通知。

graphql
subscription notificationDeleted {
  notificationDeleted { id onlyOnce isClearable appId appName postedAt silent title }
}
subscription

notificationRefreshed

接收刷新当前设备通知列表的信号。

graphql
subscription notificationRefreshed {
  notificationRefreshed
}
mutation

deleteNotifications

删除指定通知记录,并返回受影响数量。

graphql
mutation deleteNotifications($ids: [ID!]!) {
  deleteNotifications(ids: $ids) { affectedCount }
}
mutation

replyNotification

通过内联回复动作回复通知;actionIndex 是可回复动作中从 0 开始的索引。

graphql
# `actionIndex` indexes [`Notification::reply_actions`], the
# reply-capable subset — not the plain action list.
mutation replyNotification($id: ID!, $actionIndex: Int!, $text: String!) {
  replyNotification(id: $id, actionIndex: $actionIndex, text: $text)
}
query

notificationCount

统计符合查询条件的已存储通知数。

graphql
query notificationCount($query: String!) {
  notificationCount(query: $query)
}
query

notifications

分页读取符合查询条件的已存储设备通知。

graphql
query notifications($query: String!, $offset: Int!, $limit: Int!) {
  notifications(query: $query, offset: $offset, limit: $limit) { id onlyOnce isClearable appId appName postedAt silent title }
}