Shopify Admin GraphQL API undesired customer cache

Hi all!

I’ve run into an odd issue here searching though customers by their email. Here’s the query:

query GetCustomers($query: String!) {
    customers(query: $query, first: 1) {
        nodes {
            id
            locale
        }
    }
  }

And my input:

{
   "query": "email:sometesting@emailaddress.com"
}

In this case, I’ve used this email address multiple times for testing purposes, meaning I’ve created then deleted an account that was using this email.

So now when I make the query, if the first parameter is set to 1, the API will return an empty array even though there is an actual customer using the queried email address.
If I increment the first parameter, then I will end up getting my customer once I reach the value of the amount of previously deleted customer.

This also happens if a customer first subscribed using a first email address, then changed it. If another customer is created using the initial email address, I will end up retrieving both customers linked to the same email address, even though only one is currently using it.

For information, this doesn’t occur on the REST API, only on the GraphQL admin API.

How could we solve this issue?
It’s important to mention that the email address is the only data available to me on this specific workflow, querying by id is not an option.

Thanks for the help!

Having the same issue here.

Please Shopify Devs, respond to this quickly as this will and has led to production problems.

Hey @MarionOtt ,

Thanks for flagging this.

We were able to reproduce this behaviour, and have already flagged this with our developers.

I can confirm the REST customers/search.json endpoint also works on my test store, but for anyone having these empty nodes cause production problems still using GraphQL:

  • The customerConnection.pageinfo doesn’t return an endCursor for the empty node, but hasNextPage is true.
  • Adding reverse: true to your customerConnection arguments should ensure you get the expected results, regardless of if there’s an empty node in the initial results.