A space to discuss GraphQL queries, mutations, troubleshooting, throttling, and best practices.
I'm looking for some clear examples of using the metaobjectDefinitions GraphQL query, and related queries. I want to export metaobject definitions from one store, and then reimport into another store. Using a third-party app to do this isn't an option for me - I want to understand how to do this myself.
The query I'm attempting is:
{metaobjectDefinitions {idnamedescription}}
Field 'metaobjectDefinitions' doesn't exist on type 'QueryRoot', locations - line - 2, column - 5, path - query, metaobjectDefinitions, extensions - code - undefinedField, typeName - QueryRoot, fieldName - metaobjectDefinitions
Hi @Tristan3dt 👋
I'd recommend reviewing this guide on how to manage metaobjects. The `metaobjectDefinitions` query is supported for versions 2023-01+, so it may be worthwhile checking which version you're querying.
The query below should work:
{
metaobjectDefinitions (first:10) {
nodes {
id
name
description
}
}
}
Or in curl:
curl -L 'https://SHOP_NAME.myshopify.com/admin/api/2023-04/graphql.json' \
-H 'Content-Type:application/json' \
-H 'X-Shopify-Access-Token:ACCESS_TOKEN' \
-d '{"query":"{ metaobjectDefinitions (first:10) { nodes { id name description } } }"}'
Hope that helps!
Developer Support @ Shopify
- Was this reply helpful? Click Like to let us know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog