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
:String
handle
:String
firstPublishedAt
:DateTime
firstPublishedAtTimezone
:String
description
:String
seo
:SEOInput
template
:String
sectionIds
:[ID!]
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 {
id
title
handle
description
}
}
}
`;
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": [
{
"id": "section-id-1",
"title": "Section 1",
"handle": "section-1",
"description": "This is section 1."
},
{
"id": "section-id-2",
"title": "Section 2",
"handle": "section-2",
"description": "This is section 2."
}
]
}
}
}