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.

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 {
        id
        title
        handle
        description
      }
    }
  }
`;
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": [
                {
                    "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."
                }
            ]
        }
    }
}

Was this page helpful?