cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
DennisSheridan
New Member

Help with GraphQL paginated query

Hi, I'm having trouble using GraphQL with pagination to retrieve all Courses and related Sections from our Canvas instance. Using a Powershell script, I'm generating these requests:

First request:
{ account (id: "123456") { coursesConnection(first: 500, after: "") { pageInfo { endCursor hasNextPage } nodes { _id sectionsConnection { nodes { _id }}}}}}

The first request returns 500 courses with associated sections. The 'endCursor' value is 'ABC'

Second request:
{ account (id: "123456") { coursesConnection(first: 500, after: "ABC") { pageInfo { endCursor hasNextPage } nodes { _id sectionsConnection { nodes { _id }}}}}}

The second request returns 500 courses with associated sections. The 'endCursor' value is 'DEF'

Third request:
{ account (id: "123456") { coursesConnection(first: 500, after: "DEF") { pageInfo { endCursor hasNextPage } nodes { _id sectionsConnection { nodes { _id }}}}}}

The third request returns 500 courses with associated sections. The 'endCursor' value is 'GHI'

… and so on until all 6150 courses are retrieved.

The problem I'm experiencing is that when I inspect the final resultset of 6150 courses I'm finding many duplicates and many missing courses. The course count of 6150 seems correct but it's as if the values being returned from each call are scrambled or overlapping somehow. I'm leaning towards "overlapping" because a Course ID will show up a maximum of two times in the final resultset (eg, Course ID 56786 will appear once or twice in the final resultset, but never three times).

Thank you!

Labels (1)
0 Kudos
0 Replies