New Shopify Certification now available: Liquid Storefronts for Theme Developers

Discrepancy in GraphQL Response for Metafields in Shopify

Arenas1
Tourist
9 0 1

Hello all,

I'm encountering an issue with a GraphQL query on Shopify. When requesting a specific collection using a metafield (idnodo with value 560), the response I get is for a collection with a metafield idnodo value of 591.

Has anyone experienced something similar or has any insights on why this might be happening? I've attached my GraphQL query and the response for further details.


Query

 

{
  collections(first: 1, query: "metafield:custom.idnodo.value=588") {
    edges {
      node {
        id
        title
        metafields(first: 1, namespace: "custom") {
          edges {
            node {
              key
              value
            }
          }
        }
      }
    }
  }
}

 

Response

 

{
  "data": {
    "collections": {
      "edges": [
        {
          "node": {
            "id": "gid://shopify/Collection/403918323931",
            "title": "MURAL",
            "metafields": {
              "edges": [
                {
                  "node": {
                    "key": "idnodo",
                    "value": "591"
                  }
                }
              ]
            }
          }
        }
      ]
    }
  },

 



Thanks in advance for any guidance.

Replies 2 (2)
lizk
Shopify Staff
Shopify Staff
246 57 62

Hi there 👋

At this time metafields are not a supported query filter for collections. The supported query filters are: 

  • collection_type
  • product_publication_status
  • publishable_status
  • published_status
  • title
  • updated_at

When an unsupported query filter is used, it is ignored. So in your example your query is just returning the first collection. 

I definitely understand how this functionality caused confusion, and I will be relaying that to the team.

To learn more visit the Shopify Help Center or the Community Blog.

SergioSanchez
Visitor
3 0 0

Fantastic clarification, in fact the message made me think it was possible.

Many thanks for the clarification,