1. Create a Definition for Metaobject
mutation CreateMetaobjectDefinitionWithAccessAndPublish ($definition : MetaobjectDefinitionCreateInput ! ) {
metaobjectDefinitionCreate (definition : $definition ) {
metaobjectDefinition {
name
type
access {
admin
storefront
}
capabilities {
publishable {
enabled
}
}
fieldDefinitions {
name
key
}
}
userErrors {
field
message
code
}
}
}
{
"definition" : {
"name" : " CustomSwatchify" ,
"type" : " $app:swatchify" ,
"access" : {
"admin" : " PUBLIC_READ" ,
"storefront" : " PUBLIC_READ"
},
"fieldDefinitions" : [
{
"name" : " Title" ,
"key" : " title" ,
"type" : " single_line_text_field" ,
"validations" : [
{
"name" : " max" ,
"value" : " 100"
}
]
},
{
"name" : " Swatch Data" ,
"key" : " swatch_data" ,
"type" : " json"
}
]
}
}
{
"data" : {
"metaobjectDefinitionCreate" : {
"metaobjectDefinition" : {
"name" : " CustomSwatchify" ,
"type" : " app--2315872--swatchify" ,
"access" : {
"admin" : " PUBLIC_READ" ,
"storefront" : " PUBLIC_READ"
},
"capabilities" : {
"publishable" : {
"enabled" : false
}
},
"fieldDefinitions" : [
{
"name" : " Title" ,
"key" : " title"
},
{
"name" : " Swatch Data" ,
"key" : " swatch_data"
}
]
},
"userErrors" : []
}
},
"extensions" : {
"cost" : {
"requestedQueryCost" : 14 ,
"actualQueryCost" : 14 ,
"throttleStatus" : {
"maximumAvailable" : 1000 ,
"currentlyAvailable" : 986 ,
"restoreRate" : 50
}
}
}
}
Populate A metaobject of the above type
mutation UpsertMetaobject ($handle : MetaobjectHandleInput ! , $metaobject : MetaobjectUpsertInput ! ) {
metaobjectUpsert (handle : $handle , metaobject : $metaobject ) {
metaobject {
handle
title : field (key : " title" ) {
value
}
swatch_data : field (key : " swatch_data" ){
value
}
}
userErrors {
field
message
code
}
}
}
{
"handle" : {
"type" : " app--2315872--swatchify" ,
"handle" : " abc2"
},
"metaobject" : {
"fields" : [
{
"key" : " title" ,
"value" : " swatch abc 2"
},
{
"key" : " swatch_data" ,
"value": "{\"moHandle\":\"abc2\",\"name\":\"swatch abc 1\",\"palettes\":{\"battery\":{\"isActive\":true,\"palette\":{\"1100ma\":\"https://cdn.shopify.com/s/files/1/0654/5198/3077/files/1100-ma-battery.png?v=1659625612\",\"1800ma\":\"https://cdn.shopify.com/s/files/1/0654/5198/3077/files/1800-ma-battery.png?v=1659625612\"},\"shape\":{\"width\":\"60\",\"height\":\"60\",\"border\":false,\"borderRadius\":\"4\",\"borderWidth\":\"1\",\"borderColor\":\"#a6a4a4\",\"borderColorChecked\":\"#ff0000\"},\"usingSharedPalette\":false},\"coil type\":{\"isActive\":true,\"palette\":{\"quartz\":\"https://cdn.shopify.com/s/files/1/0654/5198/3077/files/quartz.jpg?v=1659720216\",\"ceramic\":\"https://cdn.shopify.com/s/files/1/0654/5198/3077/files/ceramic.jpg?v=1659720216\"},\"shape\":{\"width\":\"120\",\"height\":\"120\",\"border\":false,\"borderRadius\":\"4\",\"borderWidth\":\"1\",\"borderColor\":\"#a6a4a4\",\"borderColorChecked\":\"#ff0000\"},\"usingSharedPalette\":false},\"color\":{\"isActive\":true,\"palette\":{\"silver\":\"#101211\",\"black\":\"#000000\",\"pakura pink\":\"#5f4172\",\"apple green\":\"#2c2b46\",\"azure green\":\"#62749b\"},\"shape\":{\"width\":\"120\",\"height\":\"120\",\"border\":false,\"borderRadius\":\"4\",\"borderWidth\":\"1\",\"borderColor\":\"#a6a4a4\",\"borderColorChecked\":\"#ff0000\"},\"usingSharedPalette\":false}},\"scope\":[\"gid://shopify/Product/7923552420069\",\"gid://shopify/Product/7923221692645\",\"gid://shopify/Product/7923288637669\"]}"
}
]
}
}
{
"data" : {
"metaobjectUpsert" : {
"metaobject" : {
"handle" : " abc2" ,
"title" : {
"value" : " swatch abc 2"
},
"swatch_data" : {
"value": "{\"moHandle\":\"abc2\",\"name\":\"swatch abc 1\",\"palettes\":{\"battery\":{\"isActive\":true,\"palette\":{\"1100ma\":\"https://cdn.shopify.com/s/files/1/0654/5198/3077/files/1100-ma-battery.png?v=1659625612\",\"1800ma\":\"https://cdn.shopify.com/s/files/1/0654/5198/3077/files/1800-ma-battery.png?v=1659625612\"},\"shape\":{\"width\":\"60\",\"height\":\"60\",\"border\":false,\"borderRadius\":\"4\",\"borderWidth\":\"1\",\"borderColor\":\"#a6a4a4\",\"borderColorChecked\":\"#ff0000\"},\"usingSharedPalette\":false},\"coil type\":{\"isActive\":true,\"palette\":{\"quartz\":\"https://cdn.shopify.com/s/files/1/0654/5198/3077/files/quartz.jpg?v=1659720216\",\"ceramic\":\"https://cdn.shopify.com/s/files/1/0654/5198/3077/files/ceramic.jpg?v=1659720216\"},\"shape\":{\"width\":\"120\",\"height\":\"120\",\"border\":false,\"borderRadius\":\"4\",\"borderWidth\":\"1\",\"borderColor\":\"#a6a4a4\",\"borderColorChecked\":\"#ff0000\"},\"usingSharedPalette\":false},\"color\":{\"isActive\":true,\"palette\":{\"silver\":\"#101211\",\"black\":\"#000000\",\"pakura pink\":\"#5f4172\",\"apple green\":\"#2c2b46\",\"azure green\":\"#62749b\"},\"shape\":{\"width\":\"120\",\"height\":\"120\",\"border\":false,\"borderRadius\":\"4\",\"borderWidth\":\"1\",\"borderColor\":\"#a6a4a4\",\"borderColorChecked\":\"#ff0000\"},\"usingSharedPalette\":false}},\"scope\":[\"gid://shopify/Product/7923552420069\",\"gid://shopify/Product/7923221692645\",\"gid://shopify/Product/7923288637669\"]}"
}
},
"userErrors" : []
}
},
"extensions" : {
"cost" : {
"requestedQueryCost" : 12 ,
"actualQueryCost" : 12 ,
"throttleStatus" : {
"maximumAvailable" : 1000 ,
"currentlyAvailable" : 988 ,
"restoreRate" : 50
}
}
}
}
Query the Type for its nodes
query getMetaobjects ($type : String ! ){
metaobjects (type : $type , first :100 ) {
nodes {
handle ,
capabilities {
publishable {
status
}
}
fields {
key
value
}
}
}
}
json {"type": "app--2315872--swatchify"}
{
"data" : {
"metaobjects" : {
"nodes" : [
{
"handle" : " abc1" ,
"capabilities" : {
"publishable" : null
},
"fields" : [
{
"key" : " title" ,
"value" : " swatch abc 1"
},
{
"key" : " swatch_data" ,
"value": "{\"moHandle\":\"abc1\",\"name\":\"swatch abc 1\",\"palettes\":{\"battery\":{\"isActive\":true,\"palette\":{\"1100ma\":\"https://cdn.shopify.com/s/files/1/0654/5198/3077/files/1100-ma-battery.png?v=1659625612\",\"1800ma\":\"https://cdn.shopify.com/s/files/1/0654/5198/3077/files/1800-ma-battery.png?v=1659625612\"},\"shape\":{\"width\":\"60\",\"height\":\"60\",\"border\":false,\"borderRadius\":\"4\",\"borderWidth\":\"1\",\"borderColor\":\"#a6a4a4\",\"borderColorChecked\":\"#ff0000\"},\"usingSharedPalette\":false},\"coil type\":{\"isActive\":true,\"palette\":{\"quartz\":\"https://cdn.shopify.com/s/files/1/0654/5198/3077/files/quartz.jpg?v=1659720216\",\"ceramic\":\"https://cdn.shopify.com/s/files/1/0654/5198/3077/files/ceramic.jpg?v=1659720216\"},\"shape\":{\"width\":\"120\",\"height\":\"120\",\"border\":false,\"borderRadius\":\"4\",\"borderWidth\":\"1\",\"borderColor\":\"#a6a4a4\",\"borderColorChecked\":\"#ff0000\"},\"usingSharedPalette\":false},\"color\":{\"isActive\":true,\"palette\":{\"silver\":\"#101211\",\"black\":\"#000000\",\"pakura pink\":\"#5f4172\",\"apple green\":\"#2c2b46\",\"azure green\":\"#62749b\"},\"shape\":{\"width\":\"120\",\"height\":\"120\",\"border\":false,\"borderRadius\":\"4\",\"borderWidth\":\"1\",\"borderColor\":\"#a6a4a4\",\"borderColorChecked\":\"#ff0000\"},\"usingSharedPalette\":false}},\"scope\":[\"gid://shopify/Product/7923552420069\",\"gid://shopify/Product/7923221692645\",\"gid://shopify/Product/7923288637669\"]}"
}
]
},
{
"handle" : " abc2" ,
"capabilities" : {
"publishable" : null
},
"fields" : [
{
"key" : " title" ,
"value" : " swatch abc 2"
},
{
"key" : " swatch_data" ,
"value": "{\"moHandle\":\"abc2\",\"name\":\"swatch abc 1\",\"palettes\":{\"battery\":{\"isActive\":true,\"palette\":{\"1100ma\":\"https://cdn.shopify.com/s/files/1/0654/5198/3077/files/1100-ma-battery.png?v=1659625612\",\"1800ma\":\"https://cdn.shopify.com/s/files/1/0654/5198/3077/files/1800-ma-battery.png?v=1659625612\"},\"shape\":{\"width\":\"60\",\"height\":\"60\",\"border\":false,\"borderRadius\":\"4\",\"borderWidth\":\"1\",\"borderColor\":\"#a6a4a4\",\"borderColorChecked\":\"#ff0000\"},\"usingSharedPalette\":false},\"coil type\":{\"isActive\":true,\"palette\":{\"quartz\":\"https://cdn.shopify.com/s/files/1/0654/5198/3077/files/quartz.jpg?v=1659720216\",\"ceramic\":\"https://cdn.shopify.com/s/files/1/0654/5198/3077/files/ceramic.jpg?v=1659720216\"},\"shape\":{\"width\":\"120\",\"height\":\"120\",\"border\":false,\"borderRadius\":\"4\",\"borderWidth\":\"1\",\"borderColor\":\"#a6a4a4\",\"borderColorChecked\":\"#ff0000\"},\"usingSharedPalette\":false},\"color\":{\"isActive\":true,\"palette\":{\"silver\":\"#101211\",\"black\":\"#000000\",\"pakura pink\":\"#5f4172\",\"apple green\":\"#2c2b46\",\"azure green\":\"#62749b\"},\"shape\":{\"width\":\"120\",\"height\":\"120\",\"border\":false,\"borderRadius\":\"4\",\"borderWidth\":\"1\",\"borderColor\":\"#a6a4a4\",\"borderColorChecked\":\"#ff0000\"},\"usingSharedPalette\":false}},\"scope\":[\"gid://shopify/Product/7923552420069\",\"gid://shopify/Product/7923221692645\",\"gid://shopify/Product/7923288637669\"]}"
}
]
}
]
}
},
"extensions" : {
"cost" : {
"requestedQueryCost" : 402 ,
"actualQueryCost" : 9 ,
"throttleStatus" : {
"maximumAvailable" : 1000 ,
"currentlyAvailable" : 991 ,
"restoreRate" : 50
}
}
}
}