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.

Re: Trying to add a new entry for the meta-object with API

Solved

Trying to add a new entry for the meta-object with API

teddybear_d9
Shopify Partner
12 1 2

Hi,
I’m trying to add a new entry for the meta-object called product_relationship, I mean new data like a new product in the product object so the same for meta-object API,
I read this documentation
https://shopify.dev/docs/apps/custom-data/metaobjects/manage-metaobjects 
I tried this request according to the guide:

 

mutation {
  metaobjectCreate(metaobject: {
    type: "$app:product_relationship",
    fields: [
      {
        key: "group",
        value: "b"
      },
      {
        key: "prodcut",
        value: "gid://shopify/prodcut/6931492569178"
      }
    ]
  }) {
    metaobject {
      id
      type
      group: field(key: "group") { value }
      prodcut: field(key: "prodcut") { value },
    }
  }
}

But I get this response:

 

 

 

 

{
    "data": {
        "metaobjectCreate": {
            "metaobject": null
        }
    },
    "extensions": {
        "cost": {
            "requestedQueryCost": 12,
            "actualQueryCost": 10,
            "throttleStatus": {
                "maximumAvailable": 2000.0,
                "currentlyAvailable": 1990,
                "restoreRate": 100.0
            }
        }
    }
}

 

 

 

 Thanks!

Accepted Solution (1)

Liam
Community Manager
3108 344 911

This is an accepted solution.

Hi Neryaelul,

 

This does sound strange - did running metaobjectDefinitionCreate before (like in step 1 here) work as expected? 

Liam | Developer Advocate @ Shopify 
 - Was my reply helpful? Click Like to let me 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

View solution in original post

Replies 3 (3)

Liam
Community Manager
3108 344 911

This is an accepted solution.

Hi Neryaelul,

 

This does sound strange - did running metaobjectDefinitionCreate before (like in step 1 here) work as expected? 

Liam | Developer Advocate @ Shopify 
 - Was my reply helpful? Click Like to let me 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

teddybear_d9
Shopify Partner
12 1 2

The problem was that I couldn't add it because it seems that definition meta-objects created in the administration interface (admin) cannot be added to them in the API App.

Liam
Community Manager
3108 344 911

Glad you figured out the problem! 

Liam | Developer Advocate @ Shopify 
 - Was my reply helpful? Click Like to let me 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