Anchor to blogUpdateblog
blogUpdate
mutation
Requires Any of ,
access scopes.
Updates a blog.
Anchor to Arguments
Arguments
- Anchor to blogblog•Blog
Update requiredInput! The properties of the blog to be updated.
- •ID!required
The ID of the blog to be updated.
Was this section helpful?
Anchor to BlogUpdatePayload returnsBlogUpdatePayload returns
- Anchor to blogblog•
The blog that was updated.
- Anchor to userErrorsuser•
Errors [BlogUpdate non-nullUser Error!]! The list of errors that occurred from executing the mutation.
Was this section helpful?
- Modify an existing Blog
- blogUpdate reference
Examples
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
mutation UpdateBlog($id: ID!, $blog: BlogUpdateInput!) {
blogUpdate(id: $id, blog: $blog) {
blog {
id
title
handle
templateSuffix
commentPolicy
}
userErrors {
code
field
message
}
}
}`,
{
variables: {
"id": "gid://shopify/Blog/389767568",
"blog": {
"title": "Updated Blog Title",
"handle": "updated-blog-title",
"templateSuffix": "updated_template",
"commentPolicy": "MODERATED"
mutation UpdateBlog($id: ID!, $blog: BlogUpdateInput!) {
blogUpdate(id: $id, blog: $blog) {
blog {
id
title
handle
templateSuffix
commentPolicy
}
userErrors {
code
field
message
}
}
}
curl -X POST \
https://your-development-store.myshopify.com/admin/api/2024-10/graphql.json \
-H 'Content-Type: application/json' \
-H 'X-Shopify-Access-Token: {access_token}' \
-d '{
"query": "mutation UpdateBlog($id: ID!, $blog: BlogUpdateInput!) { blogUpdate(id: $id, blog: $blog) { blog { id title handle templateSuffix commentPolicy } userErrors { code field message } } }",
"variables": {
"id": "gid://shopify/Blog/389767568",
"blog": {
"title": "Updated Blog Title",
"handle": "updated-blog-title",
"templateSuffix": "updated_template",
"commentPolicy": "MODERATED"
}
}
}'
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
mutation UpdateBlog($id: ID!, $blog: BlogUpdateInput!) {
blogUpdate(id: $id, blog: $blog) {
blog {
id
title
handle
templateSuffix
commentPolicy
}
userErrors {
code
field
message
}
}
}`,
{
variables: {
"id": "gid://shopify/Blog/389767568",
"blog": {
"title": "Updated Blog Title",
"handle": "updated-blog-title",
"templateSuffix": "updated_template",
"commentPolicy": "MODERATED"
}
},
},
);
const data = await response.json();
const client = new shopify.clients.Graphql({session});
const data = await client.query({
data: {
"query": `mutation UpdateBlog($id: ID!, $blog: BlogUpdateInput!) {
blogUpdate(id: $id, blog: $blog) {
blog {
id
title
handle
templateSuffix
commentPolicy
}
userErrors {
code
field
message
}
}
}`,
"variables": {
"id": "gid://shopify/Blog/389767568",
"blog": {
"title": "Updated Blog Title",
"handle": "updated-blog-title",
"templateSuffix": "updated_template",
"commentPolicy": "MODERATED"
}
},
},
});
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 UpdateBlog($id: ID!, $blog: BlogUpdateInput!) {
blogUpdate(id: $id, blog: $blog) {
blog {
id
title
handle
templateSuffix
commentPolicy
}
userErrors {
code
field
message
}
}
}
QUERY
variables = {
"id": "gid://shopify/Blog/389767568",
"blog": {
"title": "Updated Blog Title",
"handle": "updated-blog-title",
"templateSuffix": "updated_template",
"commentPolicy": "MODERATED"
}
}
response = client.query(query: query, variables: variables)
Input variables
JSON{
"id": "gid://shopify/Blog/389767568",
"blog": {
"title": "Updated Blog Title",
"handle": "updated-blog-title",
"templateSuffix": "updated_template",
"commentPolicy": "MODERATED"
}
}
Response
JSON{
"blogUpdate": {
"blog": {
"id": "gid://shopify/Blog/389767568",
"title": "Updated Blog Title",
"handle": "updated-blog-title",
"templateSuffix": "updated_template",
"commentPolicy": "MODERATED"
},
"userErrors": []
}
}