Have your say in Community Polls: What was/is your greatest motivation to start your own business?
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.

Creating/updating privateMetafield in Product/Collection

Creating/updating privateMetafield in Product/Collection

gianlucasaroni
Visitor
3 0 0

Hi all,

I'm trying to add/update privateMetafield in Product/Collection following docs (https://shopify.dev/apps/metafields/private) but unfortunately I'm getting "Internal Error":

[GraphQL error]: Message: Internal error. Looks like something went wrong on our end.
Request ID: 2b568498-35e9-4d2e-b735-b90ca8f40701 (include this in support requests)., Location: undefined, Path: undefined

gql

mutation ($input: CollectionInput!){
    collectionUpdate(input: $input) {
        collection {
            privateMetafields(first:10) {
                edges {
                    node {
                        namespace
                        key
                        value
                    }
                }
            }
        }
    }
}

Input data 

{
    input: {
        id: collectionId,
        privateMetafields: [{
            namespace: "myNameSpace",
            key: "myKey",
            valueInput: {
                value: "myData",
                valueType: "STRING"
            }
        }]
    }
}
Replies 2 (2)

csam
Shopify Staff (Retired)
267 40 51

Hi @gianlucasaroni 

Thank you for providing the x-request-id for your API request. I had a look and saw that you're using the type "string" which has been deprecated. You will want to use either single_line_text_field or multiple_line_text_field.

You can see the currently valid types here: https://shopify.dev/apps/metafields/definitions/types

I'll follow up with you as well via your support ticket, as I'm not 100% certain that is the cause of the errors you've been receiving.

To learn more visit the Shopify Help Center or the Community Blog.

gianlucasaroni
Visitor
3 0 0

uhm so PrivateMetafields has the same available type of Metafields?

btw I fixed the problem on products so I'm able to set privateMetafields on it, but I have 2 more questions:

  • is it possible to add privateMetafields on Collections?
  • is it possible to query all products (or collections) that has specific privateMetafield valorized? 

 

Thanks.