filter metaobjects by field

filter metaobjects by field

AH63935
Shopify Partner
24 1 24

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
180 25 20

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
24 1 24

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

Eric-HAN
Shopify Partner
180 25 20

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
24 1 24

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

AH63935
Shopify Partner
24 1 24

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

Eric-HAN
Shopify Partner
180 25 20

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
24 1 24

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