PlainApp
API 参考

标签

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

类型定义

graphql
type Mutation {
  addToTags(type: DataType!, tagIds: [ID!]!, query: String!): Boolean!
  createTag(type: DataType!, name: String!): Tag!
  deleteTag(id: ID!): Boolean!
  removeFromTags(type: DataType!, tagIds: [ID!]!, query: String!): Boolean!
  updateTag(id: ID!, name: String!): Tag!
  updateTagRelations(type: DataType!, keys: [String!]!, addTagIds: [ID!]!, removeTagIds: [ID!]!): Boolean!
}

type Query {
  tagKeys(id: ID!): [String!]!
  tagRelations(type: DataType!, keys: [String!]!): [TagRelation!]!
  tags(type: DataType!): [Tag!]!
}

enum DataType {
	DEFAULT
	AUDIO
	VIDEO
	IMAGE
	SMS
	CONTACT
	NOTE
	FEED_ENTRY
	CALL
	PACKAGE
	FILE
	APP_FILE
	DOC
}

type Tag {
	id: ID!
	name: String!
	type: DataType!
	count: Int!
}

type TagRelation {
	tagId: ID!
	key: String!
}

操作

mutation

addToTags

为符合查询条件的全部项目添加一个或多个标签。

graphql
mutation addToTags($type: DataType!, $tagIds: [ID!]!, $query: String!) {
  addToTags(type: $type, tagIds: $tagIds, query: $query)
}
mutation

createTag

创建指定数据类型下的标签。

graphql
mutation createTag($type: DataType!, $name: String!) {
  createTag(type: $type, name: $name) { id name type count }
}
mutation

deleteTag

删除标签,并移除全部项目与该标签的关联。

graphql
mutation deleteTag($id: ID!) {
  deleteTag(id: $id)
}
mutation

removeFromTags

从符合查询条件的全部项目上移除一个或多个标签。

graphql
mutation removeFromTags($type: DataType!, $tagIds: [ID!]!, $query: String!) {
  removeFromTags(type: $type, tagIds: $tagIds, query: $query)
}
mutation

updateTag

重命名已有标签。

graphql
mutation updateTag($id: ID!, $name: String!) {
  updateTag(id: $id, name: $name) { id name type count }
}
mutation

updateTagRelations

在一次调用中为单个项目添加和/或移除标签。

graphql
mutation updateTagRelations($type: DataType!, $keys: [String!]!, $addTagIds: [ID!]!, $removeTagIds: [ID!]!) {
  updateTagRelations(type: $type, keys: $keys, addTagIds: $addTagIds, removeTagIds: $removeTagIds)
}
query

tagKeys

列出与指定标签关联的项目键。

graphql
query tagKeys($id: ID!) {
  tagKeys(id: $id)
}
query

tagRelations

查询同一数据类型下一组项目键(如媒体 ID、笔记 ID)的标签分配情况。

graphql
query tagRelations($type: DataType!, $keys: [String!]!) {
  tagRelations(type: $type, keys: $keys) { tagId key }
}
query

tags

列出指定数据类型下的全部标签。

graphql
query tags($type: DataType!) {
  tags(type: $type) { id name type count }
}