cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Community Member

Fetch List Of ALL (Un-)Published Pages For A Course Using GraphQL

Jump to solution

Hi, new member here so forgive me if this is being posted in the wrong area.

We have an ungraded course which we have dubbed our "Cyber Portal" which contains information about our cyber program spread across multiple linked Pages. I want to dynamically update the Pages' contents using the GraphQL API.

query MyQuery {
course(id: XXXXX) {
modulesConnection {
nodes {
name
moduleItems {
content {
... on Page {
id
title
}}}}}}}


When I run the above I get no results back for the specific course. However, when I do it for `allCourses{}` I get the info returned for Pages in the other courses. Is there something specific I need to do to the Pages to allow them to show up? I tested on published and unpublished and neither show up for that course. Is there a better way for me to get a list of all created Pages for a course?

Tags (3)
0 Kudos
1 Solution

Accepted Solutions
Highlighted
Adventurer III

quantumpacket

That query works for me and includes both published and unpublished pages.

This suggests it is something about the particular course, rather than the query. That query returns information about pages that are in modules. It does not return information about pages that are not in modules. I would start by verifying that the course you're pulling the information from has pages that are module items.

Also note that the All Courses is not all courses in an account. It's all courses scoped to the user making the call. It's similar to going to Courses > All Courses inside the Canvas web interface.

There are probably better ways to get lists of all of the pages as not all functionality has been rolled into graphQL yet. For example, the List pages endpoint of the Pages API will return list of all of the pages. You can then use the Update/create page endpoint to make changes to the content.

View solution in original post

1 Reply
Highlighted
Adventurer III

quantumpacket

That query works for me and includes both published and unpublished pages.

This suggests it is something about the particular course, rather than the query. That query returns information about pages that are in modules. It does not return information about pages that are not in modules. I would start by verifying that the course you're pulling the information from has pages that are module items.

Also note that the All Courses is not all courses in an account. It's all courses scoped to the user making the call. It's similar to going to Courses > All Courses inside the Canvas web interface.

There are probably better ways to get lists of all of the pages as not all functionality has been rolled into graphQL yet. For example, the List pages endpoint of the Pages API will return list of all of the pages. You can then use the Update/create page endpoint to make changes to the content.

View solution in original post