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
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
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 }
}