Update Post
The updatePost mutation allows you to update an existing post with new properties in your Teachify school.
Input Parameters
Section titled “Input Parameters”| Field | Type | Description |
|---|---|---|
id | String! | ID of the post to update |
input | AdminPostInput! | Input object containing post update details |
AdminPostInput Fields
Section titled “AdminPostInput Fields”All fields are optional on update. Only the fields present in the input are changed; omitted fields keep their current values.
| Field | Type | Description |
|---|---|---|
title | String | Post title (cannot be set to null) |
subtitle | String | Post subtitle. Pass null to clear it |
body | String | Post body content (cannot be set to null) |
excerpt | String | Post excerpt. Pass null to clear it |
slug | String | URL slug for the post. Must contain only lowercase letters, numbers, and hyphens |
accessType | String | Access type for the post (login_required, paid, public_access) |
published | Boolean | Whether the post is published |
publishedAt | Int | Unix timestamp when the post should be published (see note below) |
categoryId | String | ID 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 |
noindex | Boolean | Whether to exclude this post from search engine indexing |
userId | String | ID of the user (author) for this post |
coverPhotoUrl | String | URL 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 |
publishedAtfollowspublished: unpublishing a post clears itspublishedAt, and publishing a post without a timestamp setspublishedAtto the current time.
Return Type
Section titled “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
Section titled “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
Section titled “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
Section titled “Common Errors”| Error | Description |
|---|---|
Post not found | The specified post ID does not exist |
Title cannot be empty | The post title is required |
Body cannot be empty | The post body content is required |
Slug already exists | The provided slug is already in use by another post |
Invalid access type | The accessType must be one of: login_required, paid, public_access |
Category not found | The specified category ID does not exist |
User not found | The specified user ID does not exist |
Related Resources
Section titled “Related Resources”- Create Post - Create a new post
- Delete Post - Delete a post
- Post Management - Overview of post operations
For more information about the Teachify Admin API, please refer to the API Overview.