What's your biggest current challenge? Have your say in Community Polls along the right column.
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.

Getting only selected meta-fields with namespace and keys via admin Graphql API.

Getting only selected meta-fields with namespace and keys via admin Graphql API.

CodeForGhost
Visitor
1 0 0
metafields(
                    namespace: "custom"
                    first: 10
                ) {
                    edges {
                        node {
                            key
                            value
                        }
                    }
                }

I need to get only the selected fields in the metafields array. what should be the query for this? 
Can I use the "keys": ["field1", "field2", "field3"] as an argument in meta fields?
Reply 1 (1)

Kyle_liu
Shopify Partner
304 41 54

Hi @CodeForGhost 

 

The API you are using is no longer available. I have found an alternative, and the code is as follows

 

query: "key:rating OR key:rating_count"

 

query {
  metafieldDefinitions(first: 250, ownerType: PRODUCT, query: "key:rating OR key:rating_count") {
    edges {
      node {
        name
        key
      }
    }
  }
}

 

If this is helpful, please Like and Accept the solution.
Want to modify or custom changes on store? Let me help.
- Feel free to contact me Email Me Buy Me A Coffee