API 参考

Tags

标签按 DataType(images、audio、video、files、contacts、SMS、calls、notes)划分作用域。在此管理标签和条目分配。

类型定义

bash
type Tag {
  id: ID!
  name: String!
  count: Int!   # total items carrying this tag
}

type TagRelation {
  tagId: ID!
  key: String!  # id of the tagged item
}

# DataType scopes which content type a tag belongs to
enum DataType {
  AUDIO VIDEO IMAGE SMS CONTACT NOTE FEED_ENTRY CALL DOC PACKAGE FILE
}

# Identifies a single item by its ID key, used in updateTagRelations
input TagRelationStub {
  key: String!
}

操作

query

tags

列出指定数据类型的所有标签。

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

tagRelations

查找一个数据类型内一组条目键(例如媒体 ID、笔记 ID)的标签分配。

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

createTag

创建限定于某个数据类型的新标签。

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

updateTag

重命名现有标签。

bash
mutation UpdateTag($id: ID!, $name: String!) {
  updateTag(id: $id, name: $name) { id name }
}
mutation

deleteTag

删除标签并从所有已标记条目中移除。

bash
mutation DeleteTag($id: ID!) {
  deleteTag(id: $id)
}
mutation

addToTags

将匹配查询的所有条目添加到一个或多个标签。

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

updateTagRelations

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

bash
mutation UpdateTagRelations($type: DataType!, $item: TagRelationStub!, $addTagIds: [ID!]!, $removeTagIds: [ID!]!) {
  updateTagRelations(type: $type, item: $item, addTagIds: $addTagIds, removeTagIds: $removeTagIds)
}
mutation

removeFromTags

从一个或多个标签中移除匹配查询的所有条目。

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