Back to Content Management API
articlePublish
Publishes an article.
Arguments
- Name
id- Type
- ID!
- Description
The ID of the article you want to publish.
- Name
publishComment- Type
- String
- Description
An optional string to comment on the article publish.
- Name
includeSections- Type
- [ID!]
- Description
Optional. By default, publishing the article also publishes any of its sections with unpublished changes. Pass section IDs to publish only those sections with it.
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 ArticlePublish($id: ID!, $publishComment: String) {
articlePublish(id: $id, publishComment: $publishComment) {
id
title
handle
description
author
category
tags
sections {
nodes {
id
title
}
}
}
}
`;
const variables = {
"id": "1",
"publishComment": "Publishing article."
};
const response = await packClient.fetch(query, { variables: variables });
console.log(response.data);
Response
{
"data": {
"articlePublish": {
"id": "1",
"title": "My Article",
"handle": "my-article",
"description": "This is my article.",
"author": "John Doe",
"category": "Uncategorized",
"tags": [
"tag1",
"tag2"
],
"sections": {
"nodes": [
{
"id": "section-id-1",
"title": "Section 1"
},
{
"id": "section-id-2",
"title": "Section 2"
}
]
}
}
}
}