Update an article with new data
Description
Updating an article with all required fields and proper permissions results in a successful update and returns the updated article details.
Query
mutation UpdateArticle($id: ID!, $article: ArticleUpdateInput!) {
articleUpdate(id: $id, article: $article) {
article {
id
title
handle
body
summary
tags
image {
altText
originalSrc
}
}
userErrors {
field
message
}
}
}
Variables
{
"id": "gid://shopify/Article/959752435",
"article": {
"title": "Updated Article Title",
"handle": "updated-article-title",
"body": "This is the updated content of the article.",
"summary": "This is an updated summary of the article.",
"isPublished": true,
"publishDate": "2023-01-01T12:00:00Z",
"tags": [
"UpdatedTag1",
"UpdatedTag2"
],
"image": {
"altText": "Updated alt text for the image",
"url": "http://example.com/fake_image.jpg"
}
}
}
cURL
curl -X POST \
https://your-development-store.myshopify.com/admin/api/unstable/graphql.json \
-H 'Content-Type: application/json' \
-H 'X-Shopify-Access-Token: {access_token}' \
-d '{
"query": "mutation UpdateArticle($id: ID!, $article: ArticleUpdateInput!) { articleUpdate(id: $id, article: $article) { article { id title handle body summary tags image { altText originalSrc } } userErrors { field message } } }",
"variables": {
"id": "gid://shopify/Article/959752435",
"article": {
"title": "Updated Article Title",
"handle": "updated-article-title",
"body": "This is the updated content of the article.",
"summary": "This is an updated summary of the article.",
"isPublished": true,
"publishDate": "2023-01-01T12:00:00Z",
"tags": [
"UpdatedTag1",
"UpdatedTag2"
],
"image": {
"altText": "Updated alt text for the image",
"url": "http://example.com/fake_image.jpg"
}
}
}
}'
React Router
import { authenticate } from "../shopify.server";
export const loader = async ({request}) => {
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
mutation UpdateArticle($id: ID!, $article: ArticleUpdateInput!) {
articleUpdate(id: $id, article: $article) {
article {
id
title
handle
body
summary
tags
image {
altText
originalSrc
}
}
userErrors {
field
message
}
}
}`,
{
variables: {
"id": "gid://shopify/Article/959752435",
"article": {
"title": "Updated Article Title",
"handle": "updated-article-title",
"body": "This is the updated content of the article.",
"summary": "This is an updated summary of the article.",
"isPublished": true,
"publishDate": "2023-01-01T12:00:00Z",
"tags": [
"UpdatedTag1",
"UpdatedTag2"
],
"image": {
"altText": "Updated alt text for the image",
"url": "http://example.com/fake_image.jpg"
}
}
},
},
);
const json = await response.json();
return json.data;
}
Ruby
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 UpdateArticle($id: ID!, $article: ArticleUpdateInput!) {
articleUpdate(id: $id, article: $article) {
article {
id
title
handle
body
summary
tags
image {
altText
originalSrc
}
}
userErrors {
field
message
}
}
}
QUERY
variables = {
"id": "gid://shopify/Article/959752435",
"article": {
"title": "Updated Article Title",
"handle": "updated-article-title",
"body": "This is the updated content of the article.",
"summary": "This is an updated summary of the article.",
"isPublished": true,
"publishDate": "2023-01-01T12:00:00Z",
"tags": [
"UpdatedTag1",
"UpdatedTag2"
],
"image": {
"altText": "Updated alt text for the image",
"url": "http://example.com/fake_image.jpg"
}
}
}
response = client.query(query: query, variables: variables)
Node.js
const client = new shopify.clients.Graphql({session});
const data = await client.query({
data: {
"query": `mutation UpdateArticle($id: ID!, $article: ArticleUpdateInput!) {
articleUpdate(id: $id, article: $article) {
article {
id
title
handle
body
summary
tags
image {
altText
originalSrc
}
}
userErrors {
field
message
}
}
}`,
"variables": {
"id": "gid://shopify/Article/959752435",
"article": {
"title": "Updated Article Title",
"handle": "updated-article-title",
"body": "This is the updated content of the article.",
"summary": "This is an updated summary of the article.",
"isPublished": true,
"publishDate": "2023-01-01T12:00:00Z",
"tags": [
"UpdatedTag1",
"UpdatedTag2"
],
"image": {
"altText": "Updated alt text for the image",
"url": "http://example.com/fake_image.jpg"
}
}
},
},
});
Shopify CLI
shopify app execute \
--query \
'mutation UpdateArticle($id: ID!, $article: ArticleUpdateInput!) {
articleUpdate(id: $id, article: $article) {
article {
id
title
handle
body
summary
tags
image {
altText
originalSrc
}
}
userErrors {
field
message
}
}
}' \
--variables \
'{
"id": "gid://shopify/Article/959752435",
"article": {
"title": "Updated Article Title",
"handle": "updated-article-title",
"body": "This is the updated content of the article.",
"summary": "This is an updated summary of the article.",
"isPublished": true,
"publishDate": "2023-01-01T12:00:00Z",
"tags": [
"UpdatedTag1",
"UpdatedTag2"
],
"image": {
"altText": "Updated alt text for the image",
"url": "http://example.com/fake_image.jpg"
}
}
}'
Direct API Access
const response = await fetch('shopify:admin/api/unstable/graphql.json', {
method: 'POST',
body: JSON.stringify({
query: `
mutation UpdateArticle($id: ID!, $article: ArticleUpdateInput!) {
articleUpdate(id: $id, article: $article) {
article {
id
title
handle
body
summary
tags
image {
altText
originalSrc
}
}
userErrors {
field
message
}
}
}
`,
variables: {
"id": "gid://shopify/Article/959752435",
"article": {
"title": "Updated Article Title",
"handle": "updated-article-title",
"body": "This is the updated content of the article.",
"summary": "This is an updated summary of the article.",
"isPublished": true,
"publishDate": "2023-01-01T12:00:00Z",
"tags": [
"UpdatedTag1",
"UpdatedTag2"
],
"image": {
"altText": "Updated alt text for the image",
"url": "http://example.com/fake_image.jpg"
}
}
},
}),
});
const { data } = await response.json();
console.log(data);
Response
{
"articleUpdate": {
"article": {
"id": "gid://shopify/Article/959752435",
"title": "Updated Article Title",
"handle": "updated-article-title",
"body": "This is the updated content of the article.",
"summary": "This is an updated summary of the article.",
"tags": [
"UpdatedTag1",
"UpdatedTag2"
],
"image": {
"altText": "Updated alt text for the image",
"originalSrc": "https://cdn.shopify.com/s/files/1/2637/1970/articles/fake_image.jpg?v=1730243703"
}
},
"userErrors": []
}
}
Updates an article
Query
mutation UpdateArticle($id: ID!, $article: ArticleUpdateInput!) {
articleUpdate(id: $id, article: $article) {
article {
id
title
handle
body
summary
tags
image {
altText
originalSrc
}
}
userErrors {
code
field
message
}
}
}
Variables
{
"id": "gid://shopify/Article/959752435",
"article": {
"title": "Updated Article Title",
"handle": "updated-article-title",
"body": "This is the updated content of the article.",
"summary": "This is an updated summary of the article.",
"tags": [
"UpdatedTag1",
"UpdatedTag2"
],
"image": {
"altText": "Updated alt text for the image",
"url": "http://example.com/fake_image.jpg"
}
}
}
cURL
curl -X POST \
https://your-development-store.myshopify.com/admin/api/unstable/graphql.json \
-H 'Content-Type: application/json' \
-H 'X-Shopify-Access-Token: {access_token}' \
-d '{
"query": "mutation UpdateArticle($id: ID!, $article: ArticleUpdateInput!) { articleUpdate(id: $id, article: $article) { article { id title handle body summary tags image { altText originalSrc } } userErrors { code field message } } }",
"variables": {
"id": "gid://shopify/Article/959752435",
"article": {
"title": "Updated Article Title",
"handle": "updated-article-title",
"body": "This is the updated content of the article.",
"summary": "This is an updated summary of the article.",
"tags": [
"UpdatedTag1",
"UpdatedTag2"
],
"image": {
"altText": "Updated alt text for the image",
"url": "http://example.com/fake_image.jpg"
}
}
}
}'
React Router
import { authenticate } from "../shopify.server";
export const loader = async ({request}) => {
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
mutation UpdateArticle($id: ID!, $article: ArticleUpdateInput!) {
articleUpdate(id: $id, article: $article) {
article {
id
title
handle
body
summary
tags
image {
altText
originalSrc
}
}
userErrors {
code
field
message
}
}
}`,
{
variables: {
"id": "gid://shopify/Article/959752435",
"article": {
"title": "Updated Article Title",
"handle": "updated-article-title",
"body": "This is the updated content of the article.",
"summary": "This is an updated summary of the article.",
"tags": [
"UpdatedTag1",
"UpdatedTag2"
],
"image": {
"altText": "Updated alt text for the image",
"url": "http://example.com/fake_image.jpg"
}
}
},
},
);
const json = await response.json();
return json.data;
}
Ruby
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 UpdateArticle($id: ID!, $article: ArticleUpdateInput!) {
articleUpdate(id: $id, article: $article) {
article {
id
title
handle
body
summary
tags
image {
altText
originalSrc
}
}
userErrors {
code
field
message
}
}
}
QUERY
variables = {
"id": "gid://shopify/Article/959752435",
"article": {
"title": "Updated Article Title",
"handle": "updated-article-title",
"body": "This is the updated content of the article.",
"summary": "This is an updated summary of the article.",
"tags": [
"UpdatedTag1",
"UpdatedTag2"
],
"image": {
"altText": "Updated alt text for the image",
"url": "http://example.com/fake_image.jpg"
}
}
}
response = client.query(query: query, variables: variables)
Node.js
const client = new shopify.clients.Graphql({session});
const data = await client.query({
data: {
"query": `mutation UpdateArticle($id: ID!, $article: ArticleUpdateInput!) {
articleUpdate(id: $id, article: $article) {
article {
id
title
handle
body
summary
tags
image {
altText
originalSrc
}
}
userErrors {
code
field
message
}
}
}`,
"variables": {
"id": "gid://shopify/Article/959752435",
"article": {
"title": "Updated Article Title",
"handle": "updated-article-title",
"body": "This is the updated content of the article.",
"summary": "This is an updated summary of the article.",
"tags": [
"UpdatedTag1",
"UpdatedTag2"
],
"image": {
"altText": "Updated alt text for the image",
"url": "http://example.com/fake_image.jpg"
}
}
},
},
});
Shopify CLI
shopify app execute \
--query \
'mutation UpdateArticle($id: ID!, $article: ArticleUpdateInput!) {
articleUpdate(id: $id, article: $article) {
article {
id
title
handle
body
summary
tags
image {
altText
originalSrc
}
}
userErrors {
code
field
message
}
}
}' \
--variables \
'{
"id": "gid://shopify/Article/959752435",
"article": {
"title": "Updated Article Title",
"handle": "updated-article-title",
"body": "This is the updated content of the article.",
"summary": "This is an updated summary of the article.",
"tags": [
"UpdatedTag1",
"UpdatedTag2"
],
"image": {
"altText": "Updated alt text for the image",
"url": "http://example.com/fake_image.jpg"
}
}
}'
Direct API Access
const response = await fetch('shopify:admin/api/unstable/graphql.json', {
method: 'POST',
body: JSON.stringify({
query: `
mutation UpdateArticle($id: ID!, $article: ArticleUpdateInput!) {
articleUpdate(id: $id, article: $article) {
article {
id
title
handle
body
summary
tags
image {
altText
originalSrc
}
}
userErrors {
code
field
message
}
}
}
`,
variables: {
"id": "gid://shopify/Article/959752435",
"article": {
"title": "Updated Article Title",
"handle": "updated-article-title",
"body": "This is the updated content of the article.",
"summary": "This is an updated summary of the article.",
"tags": [
"UpdatedTag1",
"UpdatedTag2"
],
"image": {
"altText": "Updated alt text for the image",
"url": "http://example.com/fake_image.jpg"
}
}
},
}),
});
const { data } = await response.json();
console.log(data);
Response
{
"articleUpdate": {
"article": {
"id": "gid://shopify/Article/959752435",
"title": "Updated Article Title",
"handle": "updated-article-title",
"body": "This is the updated content of the article.",
"summary": "This is an updated summary of the article.",
"tags": [
"UpdatedTag1",
"UpdatedTag2"
],
"image": {
"altText": "Updated alt text for the image",
"originalSrc": "https://cdn.shopify.com/s/files/1/2637/1970/articles/fake_image.jpg?v=1730243702"
}
},
"userErrors": []
}
}