Can I get a customer's tags in GraphQL so I can add and update them? What's the best practice?

Let’s say I have a customer who is tagged with “red” and I want to add a tag with “blue”. In this mutation, it will overwrite “red”.

mutation {
      customerUpdate(input: {
        id: "gid://shopify/Customer/5908902880321",
        tags: ["blue"]
    }) {
    customer {
      lastName
    }
    userErrors {
      field
      message
    }
  }
}

So, what is the best way to get all tags first? Should I query and then in node submit the mutation with all tags + the new ones if those tags don’t exist?

Hey!

You could query all the tags first.. But maybe you can do it with one query also with the tagsAdd mutation?

https://shopify.dev/api/admin-graphql/2021-10/mutations/tagsadd