How to query a Customer by metafield using GraphQL API

Hi,

I want to query a Customer filtered by it’s metafield key/value. How can I achieve this?

Hi @Lederer ,

You can filter metafield with namespace and key, you cannot filter using value of metafield.

Query:

query Customer_Data{
  customers(first:10){
    edges{
      node{
        email
        displayName
        metafield(namespace:"custom", key:"xyz"){
        id
        namespace
        key
        value
         }       
      }
    }    
  }
}

Thanks…

-message deleted-

Hey, thanks for your answer. But this query will not filter the results. It just includes the metafields for all customers.

Does no one know a solution?

I found a way:

query MyQuery {
customerSegmentMembers(
query: "metafields.custom.dados_fiscais = ‘03305273127’ "
first: 10
) {
edges {
node {
id
}
}
totalCount
}
}

I do.

query MyQuery {
  customerSegmentMembers(
    query: "metafields.custom.dados_fiscais = 'value-metafield-here' "
    first: 10
  ) {
    edges {
      node {
        id
        lastName
        firstName
        note
      }
    }
    totalCount
  }
}