@gunesc thanks for the explanation.
Currently with GraphQL Admin API, you can only query Customers based on the properties listed here. Unfortunately metafield by value is not one of them.
You can pull the metafield value by providing key and namespace in the metafield attribute of the customers query. For example:
query {
customers(first: 100) {
edges {
node {
id
metafield(namespace: "custom", key: "favourite_color"){
id
value
}
}
}
pageInfo {
hasNextPage
endCursor
}
}
}
returns an array of customer ids and the metafield values for those customers.
{
"data": {
"customers": {
"edges": [
{
"node": {
"id": "gid://shopify/Customer/7070853234943",
"metafield": null
}
},
{
"node": {
"id": "gid://shopify/Customer/7070853267711",
"metafield": null
}
},
{
"node": {
"id": "gid://shopify/Customer/7070853300479",
"metafield": null
}
},
{
"node": {
"id": "gid://shopify/Customer/7071058657535",
"metafield": {
"id": "gid://shopify/Metafield/26440047132927",
"value": "#00c4f5"
}
}
},
{
"node": {
"id": "gid://shopify/Customer/7071098077439",
"metafield": {
"id": "gid://shopify/Metafield/26157069009151",
"value": "#00d4f0"
}
}
}
],
"pageInfo": {
"hasNextPage": false,
"endCursor": "eyJsYXN0X2lkIjo3MDcxMDk4MDc3NDM5LCJsYXN0X3ZhbHVlIjoiNzA3MTA5ODA3NzQzOSJ9"
}
}
},
"extensions": {
"cost": {
"requestedQueryCost": 20,
"actualQueryCost": 8,
"throttleStatus": {
"maximumAvailable": 2000,
"currentlyAvailable": 1992,
"restoreRate": 100
}
}
}
}
If the metafield value doesn’t exist, then the query results display null.
You can use the resulting array and filter out the elements that don’t match your criteria or are null. Also the query runs on getting first 100 customers, you will have to have handle pagination via the pageInfo cursor to get all customers. Not sure if this is more helpful.