Skip to content

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.

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.

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:

ParameterTypeDescription
filterAdminCommentFilterFilter criteria (see Filtering)
pageIntPage number for pagination
perPageIntNumber of items per page (default: 20, max: 50)
limitIntAlternative to perPage

Returns:

  • CommentPage object with:
    • nodes: Array of Comment objects
    • currentPage: Current page number
    • hasNextPage: Whether there are more pages
    • hasPreviousPage: Whether there are previous pages
    • nodesCount: Total number of items matching the query
    • totalPages: 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
}
}

The Comment object contains the following fields:

FieldTypeDescription
idString!Unique identifier
contentString!The text content of the comment
commenterUser!The user who posted the comment
createdAtInt!Unix Timestamp. When the comment was created
roleTypeStringThe role of the commenter
spamBoolean!Whether the comment is flagged as spam
commentableTypeStringType of the resource this comment belongs to (Course, Lecture, Content, Submission)
commentableNameStringName/title of the resource this comment belongs to
replyCountInt!Number of replies to this comment
commentsCommentConnectionThe replies to this comment (paginated connection)

The comments query accepts a filter parameter of type AdminCommentFilter. This allows you to narrow down results based on various criteria.

Filter FieldTypeDescription
idStringOperatorFilter by comment ID
replyStatusStringFilter by reply status: replied or unreplied
sourceTypeStringFilter by source type: course, post, or submission
spamBooleanFilter by spam status
keywordStringSearch in comment content and commenter name
createdAtIntOperatorFilter by creation timestamp (Unix seconds)

The StringOperator used in the id filter has these operations:

OperationDescription
eqEqual to
neqNot equal to
inIn a list of values
ninNot in a list of values
likeMatch text values against a pattern using wildcards (case-sensitive)
containsContains substring (case-insensitive)

The IntOperator used in the createdAt filter has these operations:

OperationDescription
eqEqual to
neqNot equal to
gtGreater than
gteGreater than or equal to
ltLess than
lteLess than or equal to

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