I found a way:
query MyQuery {
customerSegmentMembers(
query: "metafields.custom.dados_fiscais = ‘03305273127’ "
first: 10
) {
edges {
node {
id
}
}
totalCount
}
}
Problem: A developer needs to query Shopify customers filtered by specific metafield values using the GraphQL API.
Initial Response: Another user clarifies that the standard customers query can filter by metafield namespace and key, but not by metafield value. The provided query example only retrieves metafields for all customers without filtering results.
Solution Found: A workaround is discovered using the customerSegmentMembers query instead of the direct customers query. This approach allows filtering customers by metafield values through a query string format:
query: "metafields.custom.namespace_key = 'value'"
Status: Resolved. The solution includes a working code example and screenshot demonstrating successful filtering of customers based on custom metafield values. The key insight is using customer segment queries rather than direct customer queries to achieve value-based metafield filtering.
I found a way:
query MyQuery {
customerSegmentMembers(
query: "metafields.custom.dados_fiscais = ‘03305273127’ "
first: 10
) {
edges {
node {
id
}
}
totalCount
}
}