Shopify API Customer tag query returns old results that should no longer match the query

Solved
Highlighted
Tourist
5 0 1

Hi there!

 

I'm building a Shopify App using Node/React and I'm following the build a shopify app with node and react guide. I'm having an issue while querying using the Apollo Client. I'm making a query for all customers with a given tag ('pro-pending'). The UI then allows the user to "Approve" this customer which then calls a mutation that edits the customer tag 'pro-pending' to 'pro'. I then refetch the original query using the "network-only" fetchPolicy to get an updated list of customers with the 'pro-pending' tag. I'd expect the 'approved' customer to not exist in this refetch. However, I get back that user even though it doesn't have the 'pro-pending' tag any more even in the query response the tag doesn't exist. Does the Shopify API cache the query response customers for some duration of time? The query also polls every 10 seconds, and eventually I will get the result I expect, but it takes some amount of time. Is there a setting for this? 

 

If there is some nuance here, is it documented anywhere? It's an easy problem to fix with some additional filtering on my end, but this behavior seems a bit misleading. 

 

Here is my query code. The mutation is a child of this query and is working correctly. Let me know if I can provide more information and thank you for taking a look at this!

 

const GET_PENDING_PRO_APPLICANTS = gql`
  query getCustomers($query: String) {
    customers(query: $query, first: 100) {
      edges {
        node {
          id
          firstName
          lastName
          tags
        }
      }
    }
  }
`; 

     <Query
        query={GET_PENDING_PRO_APPLICANTS}
        variables={{ query: "tag:pro-pending" }}
        pollInterval={10000}
      >

 

1 Like

Success.

Shopify Staff
Shopify Staff
299 32 59

Hey there,

 

There shouldn't be any caching taking place for the GraphQL query that you're running. I attempted to test the same flow using the Shopify GraphiQL app and didn't receive any outdated customers.

 

Can you try to make the same set of queries outside of your Apollo client to see if you experience the same behaviour? It's possible that there's some caching taking place with Apollo. 

 

If not, we can take a look at other possible causes.

0 Likes
Tourist
5 0 1

Sorry it's been a while since this thread was opened. But I think you are right about it being an apollo issue. 

0 Likes
New Member
2 0 0

I've been working around this same issue across Orders and Customers for several months now. The tags on the object is correct but if you actually try to filter on tags, seems like the search data is 10 seconds behind.

To replicate in GraphiQL simply tag a customer through GraphiQL and run a search for customers that contain that tag. It will take 10 seconds to show up. Remove the tag from the customer through GraphiQL and see how it takes a further 10 seconds for the search to stop returning this customer.

 

I haven't seen this documented anywhere in shopify.

Is there some actual solution to this problem?

0 Likes