Query products by metafield value returning products that don't match

no_robotocha
Shopify Partner
51 2 9

Hello, 

 

I'm using this guide to help me create a query to the Storefront API for products which have a specific metafield namespace, key and value. 

 

However, the results include products where the value for this metafield was actually null. Is there an issue with the query or can you tell me what's going wrong?

 

Query:

 

query MetaFieldSearch {
  collection(handle: "celebration") {
    handle
    products(
      first: 10
      filters: {productMetafield: {namespace: "finder", key: "test", value: "frank"}}
    ) {
      edges {
        node {
          handle
          title
          metafield(key: "test", namespace: "finder") {
            value
            key
            namespace
          }
        }
      }
    }
  }
}

Response:

{
  "data": {
    "collection": {
      "handle": "celebration",
      "products": {
        "edges": [
          {
            "node": {
              "handle": "greetings-cards-1",
              "title": "Greetings Cards",
              "metafield": null
            }
          },
          {
            "node": {
              "handle": "birthday-cards-1",
              "title": "Birthday Cards",
              "metafield": null
            }
          },
          {
            "node": {
              "handle": "age-cards",
              "title": "Birthday Number Cards",
              "metafield": null
            }
          },
          {
            "node": {
              "handle": "cut-out-cards",
              "title": "Cut-Out Cards",
              "metafield": null
            }
          },
          {
            "node": {
              "handle": "cards",
              "title": "Celebration Cards",
              "metafield": null
            }
          },
          {
            "node": {
              "handle": "congratulations-cards",
              "title": "Congratulations Cards",
              "metafield": null
            }
          },
          {
            "node": {
              "handle": "birthday-cards",
              "title": "Birthday Greetings Cards",
              "metafield": null
            }
          },
          {
            "node": {
              "handle": "love-cards",
              "title": "Love Cards",
              "metafield": null
            }
          },
          {
            "node": {
              "handle": "everyday-cards",
              "title": "Everyday Cards",
              "metafield": null
            }
          },
          {
            "node": {
              "handle": "celebration-rosettes",
              "title": "Celebration Rosettes",
              "metafield": {
                "value": "frank",
                "key": "test",
                "namespace": "finder"
              }
            }
          }
        ]
      }
    }
  }
}

Thanks!

--
No, Robotocha!
Replies 0 (0)