-
Notifications
You must be signed in to change notification settings - Fork 323
Description
Describe the issue
We have found the problem that customers with a similar email address, who are synchronized from BC to Shopify, are not being created in Shopify.
Expected behavior
I've investigated the behavior you're experiencing, and I've identified the cause. The email field in the Shopify Admin API customer search is a tokenized field. This means that when you search without quoting the email address, the search performs partial matching on individual parts of the email (like "mail", "test", and "ch") rather than matching the exact email address.
In your case, the query email:mail@test.ch was matching the customer with email claro-murten@bluewin.ch because both emails share common tokens. This is expected behavior based on how the search syntax works.
The Solution:
To perform an exact email match, you need to wrap the email address in quotes. Here's the corrected syntax:
GraphQL Query:
{
customers(first: 1, query: "email:"mail@test.ch"") {
edges {
node {
id
email
}
}
}
}
JSON Payload:
{"query": "{ customers(first: 1, query: "email:\"mail@test.ch\"") { edges { node { id email } } } }"}
The key change is adding escaped quotes (\") around the email address in your JSON payload. This ensures the API performs an exact phrase match rather than a tokenized search.
Steps to reproduce
Synchronize new customers from BC to Shopify, where several customers with a similar email address already exist.
Additional context
No response