Comments Query
Note: The Teachify Admin API is currently under development and not yet available for public use. This documentation is provided for preview purposes only.
Overview
Section titled “Overview”The Comments API allows you to retrieve top-level comments across your school. Comments may belong to different resources such as courses, lectures, posts, and submissions. Results can be filtered by reply status, source type, spam status, and keyword.
Available Queries
Section titled “Available Queries”comments
Section titled “comments”Returns a paginated list of top-level comments for the authenticated school, ordered by creation date (newest first). Soft-deleted comments are excluded, and only top-level comments are returned (replies are available via the comments field on each comment).
Required scope: Requires the comments:read scope.
Parameters:
| Parameter | Type | Description |
|---|---|---|
filter | AdminCommentFilter | Filter criteria (see Filtering) |
page | Int | Page number for pagination |
perPage | Int | Number of items per page (default: 20, max: 50) |
limit | Int | Alternative to perPage |
Returns:
- CommentPage object with:
nodes: Array of Comment objectscurrentPage: Current page numberhasNextPage: Whether there are more pageshasPreviousPage: Whether there are previous pagesnodesCount: Total number of items matching the querytotalPages: Total number of pages
Example:
query { comments( page: 1, perPage: 10 ) { nodes { id content createdAt roleType spam commentableType commentableName replyCount commenter { id name } } currentPage hasNextPage hasPreviousPage nodesCount totalPages }}Comment Object
Section titled “Comment Object”The Comment object contains the following fields:
| Field | Type | Description |
|---|---|---|
id | String! | Unique identifier |
content | String! | The text content of the comment |
commenter | User! | The user who posted the comment |
createdAt | Int! | Unix Timestamp. When the comment was created |
roleType | String | The role of the commenter |
spam | Boolean! | Whether the comment is flagged as spam |
commentableType | String | Type of the resource this comment belongs to (Course, Lecture, Content, Submission) |
commentableName | String | Name/title of the resource this comment belongs to |
replyCount | Int! | Number of replies to this comment |
comments | CommentConnection | The replies to this comment (paginated connection) |
Filtering
Section titled “Filtering”The comments query accepts a filter parameter of type AdminCommentFilter. This allows you to narrow down results based on various criteria.
Available Filters
Section titled “Available Filters”| Filter Field | Type | Description |
|---|---|---|
id | StringOperator | Filter by comment ID |
replyStatus | String | Filter by reply status: replied or unreplied |
sourceType | String | Filter by source type: course, post, or submission |
spam | Boolean | Filter by spam status |
keyword | String | Search in comment content and commenter name |
createdAt | IntOperator | Filter by creation timestamp (Unix seconds) |
StringOperator
Section titled “StringOperator”The StringOperator used in the id filter has these operations:
| Operation | Description |
|---|---|
eq | Equal to |
neq | Not equal to |
in | In a list of values |
nin | Not in a list of values |
like | Match text values against a pattern using wildcards (case-sensitive) |
contains | Contains substring (case-insensitive) |
IntOperator
Section titled “IntOperator”The IntOperator used in the createdAt filter has these operations:
| Operation | Description |
|---|---|
eq | Equal to |
neq | Not equal to |
gt | Greater than |
gte | Greater than or equal to |
lt | Less than |
lte | Less than or equal to |
Filter Examples
Section titled “Filter Examples”Find unreplied comments:
query { comments( filter: { replyStatus: "unreplied" } ) { nodes { id content replyCount } nodesCount }}Find comments on courses:
query { comments( filter: { sourceType: "course" } ) { nodes { id content commentableType commentableName } nodesCount }}Find non-spam comments matching a keyword:
query { comments( filter: { spam: false, keyword: "refund" } ) { nodes { id content commenter { id name } } nodesCount }}Find comments created after a given time:
query { comments( filter: { createdAt: { gte: 1700000000 } } ) { nodes { id content createdAt } nodesCount }}