A space to discuss GraphQL queries, mutations, troubleshooting, throttling, and best practices.
I'm trying the new metaobjects api. After creating a metaobject definition and creating a metaobject is it possible to relation it to a product for example?
F.
Solved! Go to the solution
This is an accepted solution.
Hi @Meltin-Bit 👋
When creating the metaobjectDefinition, we can set one of the `Metaobject
Below is an example:
mutation ($input: MetaobjectDefinitionCreateInput!) {
metaobjectDefinitionCreate(definition: $input) {
metaobjectDefinition {
id
type
fieldDefinitions {
key
name
type {
name
}
}
}
}
}
With variables:
{
"input" : {
"type": "$app:product_related_metaobject",
"access": {
"admin": "MERCHANT_READ_WRITE",
"storefront": "PUBLIC_READ"
},
"capabilities": {
"publishable": {
"enabled": true
}
},
"fieldDefinitions": {
"key": "product",
"name": "Related Product",
"type": "product_reference"
}
}
}
Then to create this product-related metaobject, we can use the `metaobjectCreate` mutation as follows:
mutation($input: MetaobjectCreateInput!) {
metaobjectCreate(metaobject: $input) {
metaobject {
id
type
field(key: "product") { value }
}
}
}
With variables:
{
"input" : {
"type": "$app:product_related_metaobject",
"fields": {
"key": "product",
"value": "gid://shopify/Product/6832753737846"
}
}
}
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
This is an accepted solution.
Hey Meltin-Bit, great question!
The short answer is yes, metaobjects are available in themes using the Admin API, Liquid, and the Storefront API. This is mentioned in our overview doc here, which is a good place to get an idea of the feature. The doc also links our developer resources for each method of access, and some links to other guides on access, capabilities and metaobject management.
Cheers!
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
This is an accepted solution.
Hi @Meltin-Bit 👋
When creating the metaobjectDefinition, we can set one of the `Metaobject
Below is an example:
mutation ($input: MetaobjectDefinitionCreateInput!) {
metaobjectDefinitionCreate(definition: $input) {
metaobjectDefinition {
id
type
fieldDefinitions {
key
name
type {
name
}
}
}
}
}
With variables:
{
"input" : {
"type": "$app:product_related_metaobject",
"access": {
"admin": "MERCHANT_READ_WRITE",
"storefront": "PUBLIC_READ"
},
"capabilities": {
"publishable": {
"enabled": true
}
},
"fieldDefinitions": {
"key": "product",
"name": "Related Product",
"type": "product_reference"
}
}
}
Then to create this product-related metaobject, we can use the `metaobjectCreate` mutation as follows:
mutation($input: MetaobjectCreateInput!) {
metaobjectCreate(metaobject: $input) {
metaobject {
id
type
field(key: "product") { value }
}
}
}
With variables:
{
"input" : {
"type": "$app:product_related_metaobject",
"fields": {
"key": "product",
"value": "gid://shopify/Product/6832753737846"
}
}
}
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
Thanks, this make sense 🙂 Do you know if metaobjects are available in liquid like metafields? Something like app.metaobjects....? This would be nice inside a theme app extension.
This is an accepted solution.
Hey Meltin-Bit, great question!
The short answer is yes, metaobjects are available in themes using the Admin API, Liquid, and the Storefront API. This is mentioned in our overview doc here, which is a good place to get an idea of the feature. The doc also links our developer resources for each method of access, and some links to other guides on access, capabilities and metaobject management.
Cheers!
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