Your data. Anywhere you go.

New Relic for iOS or Android


Download on the App Store    Android App on Google play


New Relic Insights App for iOS


Download on the App Store


Learn more

Close icon

GraphQL mutation to add tags

graphql

#1

ok, usual caveat, apologies if wrong place and all that. Looking for help with GraphQL mutation to add tags to entities…

I have this mutation statement

mutation AddTagsToEntity($guid: EntityGuid!, $tag: [TaggingTagInput!]!) {
    taggingAddTagsToEntity(
        guid: $guid,
        tags: $tag
        ) {
            errors {
                message
            }
        }
}

With a Query Variable set up as

{
"guid": "MTc4MjgxOXxJTkZSQXxOQXw3MTEwNjAzNDM0MDExample",
"tag": ["test-tag4","test value"]
}

The problem is that I can get the GUID into the mutation, I can’t get the tag in, just getting a rather unhelpful error (not withstanding the grammar error in the message).

"message": "Downstream server responsed with status 400"

Anyone any tips on using Tags in a query block like this.
BTW setting the guid, and/or the tag key/value directly in the mutation works fine, as per the docs, but I like to be different :wink:


#2

Hi, @David.Bell: A TaggingTagInput is an object with a key and a collection of values. Your variable should look like this:

{
  "guid": "MTc4MjgxOXxJTkZSQXxOQXw3MTEwNjAzNDM0MDExample",
  "tag": { "key": "test-tag4", "values": [ "test value" ] }
}

#3

Thanks for the input Phil, yes I’ve got the inline mutation working fine, it’s specifically using separate variables I’d like to use.


#4

After re-reading your question, I edited my reply above. :slight_smile:


#5

Sorted :+1: Many thanks.

 {
"guid": "MTc4MjgxOXxJTkZSQXxOQXw3MTEwNjAzNDM0MDExample",
"tag": [
	{ "key": "test-tag4", "values": [ "test value" ] }
]
}

Onwards and upwards to a mega tagging session :grin: