Have your say in Community Polls: What was/is your greatest motivation to start your own business?
Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

GraphQL Query Delay - Explicitly incorrect response (Verifiable)

GraphQL Query Delay - Explicitly incorrect response (Verifiable)

CameronKaiser
Tourist
4 0 2

I am finding that there is about a 20 second delay between the mutation of an item and the queryability of that mutation in the GraphQL API. I mutate an order by adding a tag, and then I query all orders without that tag; GraphQL responds with that very order up until around 20 seconds have passed. The kicker is that the response even acknowledges that the order contains the tag! Here's an example of my query and the response:

 

Query:

{  orders(query: "-tag:giftcardsCreated AND unpaid:false AND created_at:>='2021-12-08T11:40:18-08:00'", first: 5) {
    edges {
      cursor
      node {
           id
           email
           tags
           lineItems (first: 45){
                edges {
                    node {
                        sku
                        quantity
                    }
                }
            }
        }
    }
  }
}
 
Response:
{
   "extensions": {
      etc.
   },
   "data": {
      "orders": {
         "edges": [
            {
               "cursor": "(cursor)",
               "node": {
                  "lineItems": {
                     "edges": [
                        {
                           "node": {
                              "quantity": 3,
                              "sku": "(sku)"
                           }
                        }
                     ]
                  },
                  "id": "gid://shopify/Order/(id)",
                  "email": "(email)",
                  "tags": [
                     "giftcardsCreated"
                  ]
               }
            }
         ]
      }
   }
}
 
So the query "-tag:giftcardsCreated" returns an order with "tags: giftcardsCreated". After 20 seconds, this query correctly responds with no orders.
 
But it gets worse. I decided to test this in the GraphQL app and discovered that the query actually oscillates near the 20 second mark, making the order queryable, unqueryable, and queryable again. You can test this yourself by tagging an order, then repeatedly querying it with something similar to the query I used. After about 15 seconds, you'll see that sometimes the query catches the order and sometimes it doesn't, until enough time has passed and it becomes completely unqueryable (as it should be).
 
I have not been able to find any other forum posts or documentation on this. Is the backend database different than the database that the query filter accesses, and if so, what exactly is the delay, and is it variable? I can't think of any other reason why this type of issue would exist.

 

Reply 1 (1)

Luke_K
Shopify Staff
402 66 102

Hey @CameronKaiser 

 

Many thanks for raising this and for all the detail provided, it really helped!

 

I took a deep dive into this and curiously after a series of repeated attempts, I am not able to replicate. I used both ordersUpdate and the tagsAdd mutation on Orders in my attempts to replicate and then called your same orders query.

 

When I called either of said mutations, I immediately would call the subsequent orders query and am returned no data in the response when those same query parameters - I wasn't seeing any orders using "tags: giftcardsCreated" that were returned when applying the not operator.

 

I noted that amending the orders query to remove the not operator and change it to tag:giftcardsCreated whilst keeping the other params the same actually did return my orders with my newly applied tag which was expected.

 

I noted a slight delay when querying orders that had previously had tags applied with tagsAdd actually in some cases, but we'd be talking within the realms of milli seconds.

 

I was wondering if this was still an issue for you and if so, had you any x-request-id's for any of these queries/mutations you'd raised? There may be a little more light shed on this that we can ascertain via the logs. Thanks!

 

| Shopify |
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution!