Anchor to metafieldStorefrontVisibilityCreatemetafield
metafieldStorefrontVisibilityCreate
mutationDeprecated
Requires API client to have access to the owner type and namespace.
Creates a record to make all metafields that belong to the specified resource
and have the established
namespace
and key
combination visible in the Storefront API. This mutation will be removed in a future version. Use the or
mutations with
access.storefront
set instead.
Anchor to Arguments
Arguments
- Anchor to inputinput•
Specifies the input fields for a
record.
Was this section helpful?
Anchor to MetafieldStorefrontVisibilityCreatePayload returnsMetafieldStorefrontVisibilityCreatePayload returns
- Anchor to metafieldStorefrontVisibilitymetafield•
Storefront Visibility The
that was created.
- Anchor to userErrorsuser•
Errors [UserError!]! non-null The list of errors that occurred from executing the mutation.
Was this section helpful?
- Create a metafield storefront visibility
- metafieldStorefrontVisibilityCreate reference
Examples
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
mutation CreateMetafieldStorefrontVisibility($input: MetafieldStorefrontVisibilityInput!) {
metafieldStorefrontVisibilityCreate(input: $input) {
metafieldStorefrontVisibility {
namespace
key
}
userErrors {
field
message
}
}
}`,
{
variables: {
"input": {
"namespace": "bakery",
"key": "ingredients",
"ownerType": "PRODUCT"
}
},
},
);
const data = await response.json();
mutation CreateMetafieldStorefrontVisibility($input: MetafieldStorefrontVisibilityInput!) {
metafieldStorefrontVisibilityCreate(input: $input) {
metafieldStorefrontVisibility {
namespace
key
}
userErrors {
field
message
}
}
}
curl -X POST \
https://your-development-store.myshopify.com/admin/api/2024-04/graphql.json \
-H 'Content-Type: application/json' \
-H 'X-Shopify-Access-Token: {access_token}' \
-d '{
"query": "mutation CreateMetafieldStorefrontVisibility($input: MetafieldStorefrontVisibilityInput!) { metafieldStorefrontVisibilityCreate(input: $input) { metafieldStorefrontVisibility { namespace key } userErrors { field message } } }",
"variables": {
"input": {
"namespace": "bakery",
"key": "ingredients",
"ownerType": "PRODUCT"
}
}
}'
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
mutation CreateMetafieldStorefrontVisibility($input: MetafieldStorefrontVisibilityInput!) {
metafieldStorefrontVisibilityCreate(input: $input) {
metafieldStorefrontVisibility {
namespace
key
}
userErrors {
field
message
}
}
}`,
{
variables: {
"input": {
"namespace": "bakery",
"key": "ingredients",
"ownerType": "PRODUCT"
}
},
},
);
const data = await response.json();
const client = new shopify.clients.Graphql({session});
const data = await client.query({
data: {
"query": `mutation CreateMetafieldStorefrontVisibility($input: MetafieldStorefrontVisibilityInput!) {
metafieldStorefrontVisibilityCreate(input: $input) {
metafieldStorefrontVisibility {
namespace
key
}
userErrors {
field
message
}
}
}`,
"variables": {
"input": {
"namespace": "bakery",
"key": "ingredients",
"ownerType": "PRODUCT"
}
},
},
});
session = ShopifyAPI::Auth::Session.new(
shop: "your-development-store.myshopify.com",
access_token: access_token
)
client = ShopifyAPI::Clients::Graphql::Admin.new(
session: session
)
query = <<~QUERY
mutation CreateMetafieldStorefrontVisibility($input: MetafieldStorefrontVisibilityInput!) {
metafieldStorefrontVisibilityCreate(input: $input) {
metafieldStorefrontVisibility {
namespace
key
}
userErrors {
field
message
}
}
}
QUERY
variables = {
"input": {
"namespace": "bakery",
"key": "ingredients",
"ownerType": "PRODUCT"
}
}
response = client.query(query: query, variables: variables)
Input variables
JSON{
"input": {
"namespace": "bakery",
"key": "ingredients",
"ownerType": "PRODUCT"
}
}
Response
JSON{
"metafieldStorefrontVisibilityCreate": {
"metafieldStorefrontVisibility": {
"namespace": "bakery",
"key": "ingredients"
},
"userErrors": []
}
}