Comments, Discussion Threads in GraphQL
Fetching Comments on a Video
In order to fetch the comments on a video content type, you’ll first call the Forums query and then use the ID returned from that to call the Comments query.
Step 1: Call the Forums
query
query Forums(
$courseId: ID!
) {
Forums(
courseId: $courseId
) {
id // <-- pass this into the Comments query
label
}
}
// SAMPLE VARIABLES
{
"courseId": "{{ ID from CatalogContent > displayCourse }}"
}
Step 2: Call the Comments
query
Call the Comments
query using the data returned from the Forums
query.
query Comments(
$commentableId: ID!,
$commentableType: CommentableType!,
) {
Comments(
commentableId: $commentableId,
commentableType: $commentableType,
) {
comments {
asset
assetFileName
body
}
}
}
// SAMPLE VARIABLES
{
"commentableId": "{{ ID from Forums query }}",
"commentableType": "discussionBoard"
}
Fetching Discussion Threads on a Course
To fetch a discussion thread on a course, you’ll need to call three queries consecutively: Forums, Threads, and Comments.
Step 1: Call the Forums
query
query Forums(
$courseId: ID!
) {
Forums(
courseId: $courseId
) {
id // <-- pass this into the Comments query
label
}
}
// SAMPLE VARIABLES
{
"courseId": "{{ ID from CatalogContent > displayCourse }}"
}
Step 2: Call the Threads
query
Call the Threads
query using the data returned from the Forums
query.
query Threads(
$forumId: ID!,
$courseId: ID!
) {
Threads(
forumId: $forumId,
courseId: $courseId
) {
threads {
body
id
}
}
}
// SAMPLE VARIABLES
{
"forumId": "{{ ID from Forums query }}",
"courseId": "{{ ID from CatalogContent > DisplayCourse }}"
}
Step 3: Call the Comments
query
Call the Comments
query using the data returned from the Threads
query.
query Comments(
$commentableId: ID!,
$commentableType: CommentableType!,
) {
Comments(
commentableId: $commentableId,
commentableType: $commentableType,
) {
comments {
asset
assetFileName
body
}
}
}
// SAMPLE VARIABLES
{
"commentableId": "{{ ID from Forums query }}",
"commentableType": "discussionBoard"
}
Still have a question?
Get your questions answered in our Developer Discord.