Back to Content Management API

articleUpdateBulk

Allows you to bulk update articles.

Arguments

  • Name
    ids
    Type
    [ID!]
    Description

    Array of article IDs that you want to update.

  • Name
    input
    Type
    [ArticleUpdateInput!]!
    Description

    Array of objects for each corresponding article ID to update.

    • title: String
    • handle: String
    • firstPublishedAt: DateTime
    • firstPublishedAtTimezone: String
    • description: String
    • seo: SEOInput
    • template: String
    • sectionIds: [ID!]

Returns

  • Name
    Job
    Type
    Job
    Description

    Any requested field from the Job object.

Request

import { PackClient } from '@pack/client'
const packClient = new PackClient({
  token: 'YOUR-PACK-TOKEN'
});

const query = `
  mutation ArticleUpdateBulk($ids: [ID!]!, $input: [ArticleUpdateInput!]!) {
      articleUpdateBulk(ids: $ids, input: $input) {
        id
      }
    }
`;

const variables = {
  "ids": ["article-id-1", "article-id-2"],
  "input": [
    {
      "title": "New Title",
      "handle": "new-title",
      "firstPublishedAt": "2021-01-01T00:00:00Z",
      "firstPublishedAtTimezone": "America/New_York",
      "description": "New Description",
      "seo": {
        "title": "New SEO Title",
        "description": "New SEO Description",
        "image": "https://example.com/image.jpg",
        "keywords": ["keyword1", "keyword2"]
      },
      "template": "new-template",
      "sectionIds": ["section-id-1", "section-id-2"]
    },
    {
      "title": "New Title 2",
      "handle": "new-title-2",
      "firstPublishedAt": "2021-01-01T00:00:00Z",
      "firstPublishedAtTimezone": "America/New_York",
      "description": "New Description 2",
      "seo": {
        "title": "New SEO Title 2",
        "description": "New SEO Description 2",
        "image": "https://example.com/image2.jpg",
        "keywords": ["keyword3", "keyword4"]
      },
      "template": "new-template-2",
      "sectionIds": ["section-id-3", "section-id-4"]
    }
  ]
};

const response = await packClient.fetch(query, { variables:
variables
});

console.log(response.data);


Response

{
    "data": {
        "articleUpdateBulk": {
          "id": "1"
        }
    }
}

Was this page helpful?