How to change tags of a story

For this you will need the Graphql id of the story (see How to get a Story).

And you will need to find the Global IDS of tags you want to add.

First let's search for "Global Tags" (not limited to a space) with the name

graphql
query SearchHashtags {
me {
searchGlobalTags(text: "a tag") {
tag {
id
name
}
}
searchHashtags(text:"hashtag") {
hashtag {
id
name
}
}
}
}

Expected result:

response
{
"data": {
"me": {
"searchGlobalTags": [
{
"tag": {
"id": "VGFnOjEwOQ==",
"name": "a nice tag"
}
},
{
"tag": {
"id": "VGFnOjQwMw==",
"name": "another test tag"
}
},
{
"tag": {
"id": "VGFnOjI2Nw==",
"name": "tag in two"
}
}
],
"searchHashtags": [
{
"hashtag": {
"id": "SGFzaHRhZzozMDU=",
"name": "my cool hashtag"
}
},
{
"hashtag": {
"id": "SGFzaHRhZzo0MTI=",
"name": "Nouveau hashtag"
}
}
]
}
}
}

Then Keep on the side the "id" of the tags you want to use.

This example demonstrates how to add/remove Tags and Hashtags on a given content.

graphql
mutation storyTagExample($input: StoryTagInput!) {
storyTag(input: $input) {
story {
tags {
id
name
}
hashtags {
id
name
}
}
}
}
variables
{
"input": {
"id": "STORY_ID",
"addedTags": ["TAG_ID_1", "TAG_ID_2"],
"removedTags": ["TAG_ID_3"],
"addedHashtags": ["HASHTAG_ID_1"],
"removedHashtags": []
}
}

Expected result:

response
{
"data": {
"storyTag": {
"story": {
"tags": [
{ "id": "TAG_ID_1", "name": "Tag 1" },
{ "id": "TAG_ID_1", "name": "Tag 2" }
],
"hashtags": [{ "id": "HASHTAG_ID_1", "name": "Hashtag 1" }]
}
}
}
}

Was this page helpful?