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.

Cannot use graphql API metafieldSet for onlineStorePage and onlineStoreArticle

Cannot use graphql API metafieldSet for onlineStorePage and onlineStoreArticle

jam_chan
Shopify Partner
929 23 192

I try to use metafieldSet mutation but it doesn't work for onlineStorePage and onlineStoreArticle:

 

mutation metafieldsSet($metafields: [MetafieldsSetInput!]!) {
  metafieldsSet(metafields: $metafields) {
    metafields {
      # Metafield fields
    }
    userErrors {
      field
      message
    }
  }
}
{
        "metafields": {
            "key": "test1",
            "namespace": "global",
            "ownerId": "gid://shopify/OnlineStorePage/6602811342925",
            "type": "single_line_text_field",
            "value": "123"
        }
    }

 

 

Return errors:

[{'message': 'invalid id', 'locations': [{'line': 2, 'column': 5}], 'path': ['metafieldsSet']}]

 

When I try to change the ownerId to 

I try to use metafieldSet but it doesn't work for onlineStorePage and onlineStoreArticle

 

When I try to change the ownerId to "gid://shopify/Product/1234", it works again. Why doesn't it support these 2 resources?

BYOB - Build Your Own Bundles, SPO - SEO App to research keywords & edit social link preview
Replies 4 (4)

acerill
Shopify Partner
12 1 9

It looks like metafieldsSet does not work for the following 3 ID formats. Is it a bug? Or should the format of these ID's be different?

gid://shopify/OnlineStoreBlog/xxx
gid://shopify/OnlineStoreArticle/xxx
gid://shopify/OnlineStorePage/xxx

 Thanks

fzoccara_sintra
Shopify Partner
7 0 7

Try with newer api versions, I'd the same issues with company gid and using 2023-01 api version I make my day!

von_court
Shopify Partner
1 0 0

OnlineStorePage still not working with 2023-04, error response persists.

Used the REST API instead.

K-Co
Shopify Partner
7 0 4

It works now (but you still can't mutate actual articles)

 

source: https://shopify.dev/changelog/graphql-admin-api-support-for-metafield-connections-in-online-store-ob...

 

Effective April 29, 2024

As of version 2024-07 of the GraphQL Admin API, you can use the Metafield and MetafieldDefinition connections in the OnlineStoreArticle, OnlineStoreBlog, and OnlineStorePage objects.

Previously, you could only do this using the REST API.