Back to Content Management API

blogUpdate

Updates a blog.

Arguments

  • Name
    id
    Type
    ID!
    Description

    The ID of the blog you want to update.

  • Name
    input
    Type
    BlogUpdateInput!
    Description

    An object.

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

Returns

  • Name
    Blog.*
    Type
    Blog
    Description

    Any requested field from the Blog object.

Request

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

const query = `
  mutation BlogUpdate($id: ID!, $input: BlogUpdateInput!) {
    blogUpdate(id: $id, input: $input) {
      id
      title
      handle
      description
    }
  }
`;

const variables = {
  "id": "YOUR-BLOG-ID",
  "input": {
    "title": "New Blog Title",
    "handle": "new-blog-title",
    "description": "New blog description",
    "seo": {
      "title": "New Blog Title",
      "description": "New blog description",
      "image": "https://example.com/image.jpg",
      "keywords": ["new", "blog", "keywords"]
    },
    "template": "blog-template",
    "sectionIds": ["YOUR-SECTION-ID"]
  }
};

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

Response

{
  "data": {
    "blogUpdate": {
      "id": "blog-id-1",
      "title": "New Blog Title",
      "handle": "new-blog-title",
      "description": "New blog description"
    }
  }
}

Was this page helpful?