Loopwise Docs
Admin APIMutations

Post Mutations

Mutation operations for managing posts in your Loopwise school

The post mutations allow you to create, update, and delete posts within your Loopwise school. These operations enable you to programmatically manage your blog content and article publishing.

Available mutations:

  • createPost — Creates a new post
  • updatePost — Updates an existing post
  • deletePost — Deletes a post (soft delete)

All post mutations return an errors field in the response that will contain any validation or processing errors that occurred during the operation.

Post Access Types

Posts support different access types:

  • login_required — Users must be logged in to access
  • paid — Users must have purchased access
  • public_access — Available to all users

Create a Post

The createPost mutation allows you to create a new post in your Loopwise school with the specified properties.

Input Parameters

FieldTypeDescription
inputAdminPostInput!Input object containing post creation 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 AdminPostCreatePayload {
  # Array of error messages, if any occurred during the operation
  errors: [String!]

  # The created post object, null if operation failed
  post: AdminPost
}

Example

mutation CreatePost {
  createPost(input: {
    title: "Getting Started with GraphQL"
    subtitle: "A comprehensive guide for beginners"
    body: "GraphQL is a query language for APIs..."
    excerpt: "Learn the basics of GraphQL"
    slug: "getting-started-with-graphql"
    accessType: "public_access"
    published: true
    tagList: ["graphql", "tutorial", "api"]
  }) {
    post {
      id
      title
      subtitle
      slug
      accessType
      published
      tags
    }
    errors
  }
}

Sample Response

{
  "data": {
    "createPost": {
      "post": {
        "id": "post_12345",
        "title": "Getting Started with GraphQL",
        "subtitle": "A comprehensive guide for beginners",
        "slug": "getting-started-with-graphql",
        "accessType": "public_access",
        "published": true,
        "tags": ["graphql", "tutorial", "api"]
      },
      "errors": []
    }
  }
}

Common Errors

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

Update a Post

The updatePost mutation allows you to update an existing post with new properties in your Loopwise 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

Delete a Post

The deletePost mutation allows you to delete a post from your Loopwise school. This is a soft delete operation, meaning the post data is retained but marked as deleted.

Input Parameters

FieldTypeDescription
idString!ID of the post to delete

Return Type

type AdminPostDeletePayload {
  # Array of error messages, if any occurred during the operation
  errors: [String!]

  # Boolean indicating whether the deletion was successful
  success: Boolean
}

Example

mutation DeletePost {
  deletePost(id: "post_12345") {
    success
    errors
  }
}

Sample Response

{
  "data": {
    "deletePost": {
      "success": true,
      "errors": []
    }
  }
}

Error Response

If the deletion fails, you might receive a response like this:

{
  "data": {
    "deletePost": {
      "success": false,
      "errors": ["Post not found"]
    }
  }
}

Common Errors

ErrorDescription
Post not foundThe specified post ID does not exist
Post already deletedThe post has already been deleted
Insufficient permissionsYou don't have permission to delete this post

Important Notes

  • This is a soft delete operation — the post data is retained in the system but marked as deleted
  • Deleted posts will not appear in regular queries
  • The post can potentially be restored by system administrators if needed
  • All associated data (comments, ratings, etc.) will also be hidden when the post is deleted

On this page