通过 GraphQL 使用自定义表情符号
此开发中的功能可能无法供您使用。可能会有启用仍在开发中的功能所带来的风险。 详情请参见此功能的版本历史记录。
要在评论和描述中使用自定义表情符号,您可以使用 GraphQL API 将其添加到群组中。
参数:
参数 | 类型 | 是否必需 | 描述 |
---|---|---|---|
group_path
| integer/string | Yes | ID 或 URL 编码的群组路径 |
name
| string | Yes | 自定义表情符号的名称 |
file
| string | Yes | 自定义表情符号镜像的 URL |
创建自定义表情符号
mutation CreateCustomEmoji($groupPath: ID!) {
createCustomEmoji(input: {groupPath: $groupPath, name: "party-parrot", file: "https://cultofthepartyparrot.com/parrots/hd/parrot.gif", external: true}) {
clientMutationId
name
errors
}
}
将自定义表情添加到群组后,成员可以像使用评论中的其他表情一样进行使用。
获取群组的自定义表情符号
query GetCustomEmoji($groupPath: ID!) {
group(fullPath: $groupPath) {
id
customEmoji {
nodes {
name
}
}
}
}
设置 GraphiQL Explorer
此过程提供了一个实质性示例,您可以将其复制并粘贴到 GraphiQL Explorer。 GraphiQL Explorer 可用于:
- https://jihulab.com/-/graphql-explorer 上的 JiHuLab.com 用户。
-
https://gitlab.example.com/-/graphql-explorer
上的私有化部署用户。
- 复制以下代码摘录:
query GetCustomEmoji {
group(fullPath: "gitlab-org") {
id
customEmoji {
nodes {
name,
url
}
}
}
}
- 打开 GraphiQL Explorer 工具。
- 将上面列出的
query
粘贴到 GraphiQL Explorer 工具的左侧窗口中。 - 选择 Play,显示以下内容:
更多关于:
- GraphQL 特定实体的信息,例如分片和接口,请参见官方的 GraphQL 文档。
- 个别属性,请参见 GraphQL API 资源。
启用或禁用自定义表情符号 API
自定义表情符号正在开发中,但已准备好用于生产。其部署在默认禁用的功能标志后面。 有权访问极狐GitLab Rails 控制台的极狐GitLab 管理员可以进行启用。
启用:
Feature.enable(:custom_emoji)
禁用:
Feature.disable(:custom_emoji)