Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

filter metaobjects by field

filter metaobjects by field

AH63935
Shopify Partner
37 1 27

If I have a defined Metaobject definition with a field named "color", how would I fetch only these metaobjects that only have a color of "blue"?  The docs so far only refer to "first" / "last" options and "after/before". Thanks!

Replies 7 (7)

Eric-HAN
Shopify Partner
290 30 31

Hi ,there

You could refer to below

 

 

query FilterMetaobjects {
  metaobjects(type:"xxxxx",first:10,query:"display_name:blue") {
    nodes {
      id
      type
      handle
      displayName
      fields {
        key
        value
      }
    }
  }
}

 

 

Also you need to enable the checkbox "Use this field as display_name"

- Helpful? Please hit Like and mark it as a solution
Want to modify or custom changes on store? Let me help.
- Feel free to Email Me    Buy Me A Coffee
AH63935
Shopify Partner
37 1 27

Hi! I'll give that a try! How can I find that checkbox you are referring to?

Eric-HAN
Shopify Partner
290 30 31

EricHAN_0-1723078463884.png

 

- Helpful? Please hit Like and mark it as a solution
Want to modify or custom changes on store? Let me help.
- Feel free to Email Me    Buy Me A Coffee
AH63935
Shopify Partner
37 1 27

Hi, is there no other way to do this if it is not the display name?

AH63935
Shopify Partner
37 1 27

And is there any way to leave out first or last? I would want all metaobjects of that type. Thanks!

Eric-HAN
Shopify Partner
290 30 31

Currently, I believe that either the first or last field is mandatory, and you are required to paginate all of the metaobjects.

- Helpful? Please hit Like and mark it as a solution
Want to modify or custom changes on store? Let me help.
- Feel free to Email Me    Buy Me A Coffee
AH63935
Shopify Partner
37 1 27

Ah, darn. That's inconvenient. Thank you!!