Back to Content Management API

blogUpdateBulk

Allows you to bulk update blogs.

Arguments

  • Name
    ids
    Type
    [ID!]
    Description

    Array of blog IDs that you want to update.

  • Name
    input
    Type
    [BlogUpdateInput!]!
    Description

    Array of objects for each corresponding blog 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 BlogUpdateBulk($ids: [ID!]!, $input: [BlogUpdateInput!]!) {
    blogUpdateBulk(ids: $ids, input: $input) {
      id
      title
      handle
      description
      author
      category
      tags
      sections {
        id
        title
        handle
        description
      }
    }
  }
`;

const variables = {
  "ids": ["blog-id-1", "blog-id-2"],
  "input": [
    {
      "title": "New Blog Title",
      "handle": "new-blog-title",
      "description": "New blog description",
      "firstPublishedAt": "2022-01-01T00:00:00Z",
      "firstPublishedAtTimezone": "UTC",
      "seo": {
        "title": "New Blog Title",
        "description": "New blog description",
        "image": "https://example.com/image.jpg",
        "keywords": ["keyword1", "keyword2"]
      },
      "template": "blog-template",
      "sectionIds": ["section-id-1", "section-id-2"]
    }
  ]
};


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

Response

{
  "data": {
    "blogUpdateBulk": {
      "id": "blog-id-1",
      "title": "New Blog Title",
      "handle": "new-blog-title",
      "description": "New blog description",
      "author": "Author Name",
      "category": "Category Name",
      "tags": ["tag1", "tag2"],
      "sections": [
        {
          "id": "section-id-1",
          "title": "Section Title",
          "handle": "section-title",
          "description": "Section Description"
        },
        {
          "id": "section-id-2",
          "title": "Section Title 2",
          "handle": "section-title-2",
          "description": "Section Description 2"
        }
      ]
    }
  }
}

Was this page helpful?