Tagging orders via GraphQL not always working

Tagging orders via GraphQL not always working

yangli_1r
Visitor
2 0 1

Hi,

We are working on a custom APP which will tag orders after certain actions. Basically, after we processed an order (transactional email integration with SalesForce) we want to assign a tag e.g. "email_order_create:xxxx" to the order. We using GraphQL mutation::tagsAdd endpoint to tag the order, which works but not consistent. 

We log response for each "tagsAdd" call, none of them indicates an error, but sometime the order is not tagged correctly (after the "success" tag adding response, we check the order in both admin and via get order API, the tag is not there even the response saying nothing in error), here is a few example add tag responses:

Tagging Status:
{
  tagsAdd: { node: { id: 'gid://shopify/Order/2160450175073' }, userErrors: [] }
}


Here is our request (API call)

# Query
mutation OrderTagsAdd($order_id: ID!, $order_tags: [String!]!) {
    tagsAdd(id: $order_id, tags: $order_tags) {
        node {
            id
        }
        userErrors {
            field
            message
        }
    }
}
# Variables
{
  "order_id": "gid://shopify/Order/2160450175073",
  "order_tags": ["email_order_create:2160450175073"]
}

Again, it's working but just not consistent, which make the trouble shooting hard since we are not able to identify what's causing the inconsistency. Can any one help or share some idea in how to trouble shooting this type of issue?


Thank you very much!

Replies 10 (10)

vix
Shopify Staff
540 103 122

Hey @yangli_1r 


I can help you troubleshoot this. When an order is not tagged, can you note the x-request-id from the header and post it back to me? That will help me see what is happening behind the scenes. Do you have any other flows that run that could introduce a race condition? 

To learn more visit the Shopify Help Center or the Community Blog.

yesyo
Shopify Partner
8 0 2

Hi Vix,

 

We're also experiencing something similar. We add tags to orders in orders/paid webhook. Most of the time the tags are added correctly, but sometimes they are not. Also There's no error in the response.

 

I might be able to get the X-Request-ID if that's helpful.

 

Thanks.

oliverjenks
Shopify Partner
3 0 1

I've come across this thread with the similar issue.  It is the same intermittent failure (maybe one order every two days) with no userErrors.

 

I am calling a mutation that is generated like this;

 

 

  export function TAG_ORDER(orderId, tag) {  
    return gql`
      mutation tagOrder {
        tagsAdd(id: "${orderId}", tags: ["${tag}"]) {
            userErrors {
              field
              message
            }
        }
      }
    `;
  }

 

 

The response does not return any errors, but the order does not get tagged.

 

{
    tagsAdd: { userErrors: [], __typename: 'TagsAddPayload' }
}

 

 

I saw one order last night, and the x-request-id for the mutation that did not complete is;

 

dcd32bd0-12e9-4539-958c-ed350fccbad7
 
Thanks

trawiasty
Shopify Partner
5 0 1

I'm also experiencing  a similar issue but in my case a tag is not being added in a consistent manner.

 

Here's the query:

mutation addTag {
  tagsAdd(id: "gid://shopify/Customer/<id>", tags: ["<tag>"]) {
    node {
      id
    }

    userErrors {
      message
    }
  }
}

 

The response:

{
  "tagsAdd": {
    "node": {
      "id": "gid:\/\/shopify\/Customer\/<id>"
    },
    "userErrors": []
  }
}

 

"CUSTOMERS_UPDATE" webhook is triggered and tag is not present on the customer. The "X-Request-ID" is "7e281034-1470-477d-8d22-c1ac9919f4e2".

Greg_P
Shopify Partner
41 4 30

Can somebody from Shopify look into this issue? It's a serious problem, it looks like customer tags work, but sometimes it takes few hours to see new tag in the user profile. I don't think so, that it's expected behavior.

Shopify Developer
If I have solved your issue, please mark my post as accepted solution 🙂
ShopifyDevSup
Shopify Staff
1453 238 497

Hi all, Just to let you know our team have opened an issue related to this with our developers. Thank you for bringing it to our attention. We hope to have a further update for you shortly. 

Developer Support @ Shopify
- Was this reply helpful? Click Like to let us know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

Greg_P
Shopify Partner
41 4 30

Hi @ShopifyDevSup, thanks for your answer. I have additional information. I always use tagsAdd and tagsRemove mutations and I noticed following issues:
1. After customer tag is added via API, I can't see it for a long time on customer card in Shopify admin, sometimes it takes few hours to update it.
2. After customer tag is added via API, when I tried to retrieve customer with tags using API (customer query) tag previously added is not present, but when I try to retrieve subscription contract using subscriptionContract query with user details (including tags), tag is present immediately.

3. When customer tag is added in Shopify admin it's also immediately present in customer query results.
4. When order tag is added via API it's rather immediately present in order query results, but for small amount of time, I think 5-10s the whole order is not present in orders query results with customerId and tag (just added via API) filters for query param. 

Shopify Developer
If I have solved your issue, please mark my post as accepted solution 🙂
dylanpierce
Shopify Partner
234 9 103

Thank you!

Is there a public Github issue or some other bug report that we can follow?

I would like to validate the fix as soon as it's up.

My app also relies on tagging to convey state to the merchant. Reliable tagging is very important to merchants.

Founder of Real ID - Verify your customer's real IDs easily & securely with modern A.I.

Want to see it in action? Check out our demo store.

Greg_P
Shopify Partner
41 4 30

Hello @ShopifyDevSup, do you have any news when this issue can be resolved?

Shopify Developer
If I have solved your issue, please mark my post as accepted solution 🙂

dylanpierce
Shopify Partner
234 9 103

I just want to add I've been seeing this for a long time as well.

My only current workaround is to poll orders with a search query to see if they're missing tags, and then re-tag them.

Sounds like other apps also rely on tagging to convey state to the merchant, it's very important tagging works!

Thanks for taking a look, and please let us know when a fix is up so we can validate it.

Founder of Real ID - Verify your customer's real IDs easily & securely with modern A.I.

Want to see it in action? Check out our demo store.