Skip to content

Update Post

The updatePost mutation allows you to update an existing post with new properties in your Teachify school.

FieldTypeDescription
idString!ID of the post to update
inputAdminPostInput!Input object containing post update details

All fields are optional on update. Only the fields present in the input are changed; omitted fields keep their current values.

FieldTypeDescription
titleStringPost title (cannot be set to null)
subtitleStringPost subtitle. Pass null to clear it
bodyStringPost body content (cannot be set to null)
excerptStringPost excerpt. Pass null to clear it
slugStringURL slug for the post. Must contain only lowercase letters, numbers, and hyphens
accessTypeStringAccess type for the post (login_required, paid, public_access)
publishedBooleanWhether the post is published
publishedAtIntUnix timestamp when the post should be published (see note below)
categoryIdStringID of category to associate with this post. Pass null to detach the category. List the available categories with the postCategories query
tagList[String!]Replaces the post’s tags. Pass [] to clear all tags
noindexBooleanWhether to exclude this post from search engine indexing
userIdStringID of the user (author) for this post
coverPhotoUrlStringURL to an image to set as the post cover photo. Must be a CDN URL obtained from the image upload flow; other hosts are rejected with UPLOAD-008

publishedAt follows published: unpublishing a post clears its publishedAt, and publishing a post without a timestamp sets publishedAt to the current time.

type AdminPostUpdatePayload {
# Array of error messages, if any occurred during the operation
errors: [String!]
# The updated post object, null if operation failed
post: AdminPost
}
mutation UpdatePost {
updatePost(
id: "post_12345"
input: {
title: "Advanced GraphQL Techniques"
subtitle: "Take your GraphQL skills to the next level"
body: "In this advanced guide, we'll explore..."
excerpt: "Master advanced GraphQL patterns"
slug: "advanced-graphql-techniques"
accessType: "paid"
published: true
tagList: ["graphql", "advanced", "optimization"]
}
) {
post {
id
title
subtitle
slug
accessType
published
publishedAt
tags
updatedAt
}
errors
}
}
{
"data": {
"updatePost": {
"post": {
"id": "post_12345",
"title": "Advanced GraphQL Techniques",
"subtitle": "Take your GraphQL skills to the next level",
"slug": "advanced-graphql-techniques",
"accessType": "paid",
"published": true,
"publishedAt": 1687436400,
"tags": ["graphql", "advanced", "optimization"],
"updatedAt": 1687436500
},
"errors": []
}
}
}
ErrorDescription
Post not foundThe specified post ID does not exist
Title cannot be emptyThe post title is required
Body cannot be emptyThe post body content is required
Slug already existsThe provided slug is already in use by another post
Invalid access typeThe accessType must be one of: login_required, paid, public_access
Category not foundThe specified category ID does not exist
User not foundThe specified user ID does not exist

For more information about the Teachify Admin API, please refer to the API Overview.