Back to Content Management API
blogCreate
Creates a blog.
Arguments
- Name
input
- Type
- BlogCreateInput!
- Description
An object.
title
:String!
handle
:String!
description
:String
seo
:SEOInput
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 = `
fragment BlogResourceFields on BlogResource {
title
handle
description
}
mutation BlogCreate($input: BlogCreateInput!) {
blogCreate(input: $input) {
...BlogResourceFields
}
}
`;
const variables = {
"input": {
"title": "My Blog",
"handle": "my-blog",
"description": "This is my blog",
"seo": {
"title": "My Blog",
"description": "This is my blog",
"image": "https://example.com/image.jpg",
"keywords": ["blog", "example"]
},
"sectionIds": ["section-id"]
}
};
const response = await packClient.fetch(query, { variables });
console.log(response.data);
Response
{
"data": {
"blogCreate": {
"title": "My Blog",
"handle": "my-blog",
"description": "This is my blog"
}
}
}