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

Solved
New Member
5 0 0

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}
      >

 

0 Likes

Success.

Shopify Staff
Shopify Staff
298 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
Highlighted
New Member
5 0 0

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