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:Stringhandle:StringfirstPublishedAt:DateTimefirstPublishedAtTimezone:Stringdescription:Stringseo:SEOInputtemplate:StringThe title of the template to attach.sectionIds:[ID!]templateId:IDThe ID of the template to attach. Takes precedence overtemplate.sectionOverrides:JSONSection overrides for this content, as JSON.draftId:IDLegacy, from the drafts system that Content Releases replaced. To read or write a release's changes, send theX-Pack-Release-Idheader instead. See Content Releases.
Returns
- Name
Job- Type
- Job
- Description
The
idof the background job that runs the bulk operation.
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
}
}
`;
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": "YOUR-JOB-ID"
}
}
}