Back to Content Management API
articleUpdate
Updates an article.
Arguments
- Name
id- Type
- ID!
- Description
The ID of the article you want to update.
- Name
input- Type
- ArticleUpdateInput!
- Description
An object.
title:Stringhandle:StringfirstPublishedAt:DateTimefirstPublishedAtTimezone:Stringdescription:Stringseo:SEOInputtemplate:StringThe title of the template to attach.sectionIds:[ID!]blogId:StringThe ID of the blog the article belongs to.author:Stringcategory:Stringtags:[String!]excerpt:StringbodyHtml:StringtemplateId:IDThe ID of the template to attach. Takes precedence overtemplate.sectionOverrides:JSONSection overrides for this content, as JSON.draftId:IDLegacy, from the drafts system that Content Releases replaced. To read or write a release's changes, send theX-Pack-Release-Idheader instead. See Content Releases.
Returns
- Name
Article.*- Type
- Article
- Description
Any requested field from the Article object.
Request
import { PackClient } from '@pack/client'
const packClient = new PackClient({
token: 'YOUR-PACK-TOKEN'
});
const query = `
mutation ArticleUpdate($id: ID!, $input: ArticleUpdateInput!) {
articleUpdate(id: $id, input: $input) {
id
title
handle
description
author
category
tags
sections {
nodes {
id
title
}
}
}
}
`;
const variables = {
"id": "1",
"input": {
"title": "Updated Article Title",
"handle": "updated-article-title",
"description": "Updated article description.",
"seo": {
"title": "Updated SEO Title",
"description": "Updated SEO Description",
"keywords": ["Updated", "SEO", "Keywords"]
},
"template": "updated-template",
"sectionIds": ["section-id-1", "section-id-2"]
}
};
const response = await packClient.fetch(query, { variables:
variables });
console.log(response.data);
Response
{
"data": {
"articleUpdate": {
"id": "1",
"title": "Updated Article Title",
"handle": "updated-article-title",
"description": "Updated article description.",
"author": "John Doe",
"category": "Uncategorized",
"tags": [
"tag1",
"tag2"
],
"sections": {
"nodes": [
{
"id": "section-id-1",
"title": "Section 1"
},
{
"id": "section-id-2",
"title": "Section 2"
}
]
}
}
}
}