debian-mirror-gitlab/doc/api/graphql/custom_emoji.md
2021-10-27 15:23:28 +05:30

3.8 KiB

stage group info
Plan Project Management To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/engineering/ux/technical-writing/#assignments

Use custom emojis with GraphQL (FREE SELF)

This in-development feature might not be available for your use. There can be risks when enabling features still in development. Refer to this feature's version history for more details.

To use custom emoji in comments and descriptions, you can add them to a group using the GraphQL API.

Parameters:

Attribute Type Required Description
group_path integer/string {check-circle} Yes ID or URL-encoded path of the group
name string {check-circle} Yes Name of the custom emoji.
file string {check-circle} Yes URL of the custom emoji image.

Create a custom emoji

mutation CreateCustomEmoji($groupPath: ID!) {
  createCustomEmoji(input: {groupPath: $groupPath, name: "party-parrot", file: "https://cultofthepartyparrot.com/parrots/hd/parrot.gif", external: true}) {
    clientMutationId
    name
    errors
  }
}

After adding custom emoji to the group, members can use it in the same way as other emoji in the comments.

Get custom emoji for a group

query GetCustomEmoji($groupPath: ID!) {
  group(fullPath: $groupPath) {
    id
    customEmoji {
      nodes {
        name
      }
    }
  }
}

Set up the GraphiQL explorer

This procedure presents a substantive example that you can copy and paste into GraphiQL explorer. GraphiQL explorer is available for:

  1. Copy the following code excerpt:
    query GetCustomEmoji {
      group(fullPath: "gitlab-org") {
        id
        customEmoji {
          nodes {
            name,
            url
          }
        }
      }
    }
  1. Open the GraphiQL explorer tool.
  2. Paste the query listed above into the left window of your GraphiQL explorer tool.
  3. Click Play to get the result shown here:

GraphiQL explore custom emoji query

For more information on:

Enable or disable custom emoji API (FREE SELF)

Custom emoji is under development and but ready for production use. It is deployed behind a feature flag that is disabled by default. GitLab administrators with access to the GitLab Rails console can enable it.

To enable it:

Feature.enable(:custom_emoji)

To disable it:

Feature.disable(:custom_emoji)