Skip to content

Update Post

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

Input Parameters

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

AdminPostInput Fields

FieldTypeRequiredDescription
titleString!YesPost title
subtitleStringNoPost subtitle
bodyString!YesPost body content
excerptStringNoPost excerpt
slugString!YesURL slug for the post. Must contain only lowercase letters, numbers, and hyphens
accessTypeString!YesAccess type for the post (login_required, paid, public_access)
publishedBooleanNoWhether the post is published
publishedAtIntNoUnix timestamp when the post should be published
categoryIdStringNoID of category to associate with this post
tagList[String!]NoTags to associate with this post
userIdStringNoID of the user (author) for this post

Return Type

type AdminPostUpdatePayload {
# Array of error messages, if any occurred during the operation
errors: [String!]
# The updated post object, null if operation failed
post: AdminPost
}

Example

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
}
}

Sample Response

{
"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": []
}
}
}

Common 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.