Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GraphQL needs to support pagination #669

Open
jonespm opened this issue Sep 27, 2024 · 2 comments
Open

GraphQL needs to support pagination #669

jonespm opened this issue Sep 27, 2024 · 2 comments
Labels

Comments

@jonespm
Copy link
Contributor

jonespm commented Sep 27, 2024

Describe the bug

An upcoming (or recent depending on when you read this) change coming to Canvas is going to impose per page limits to GraphQL requests, previously unlimited. GraphQL call isn't paginated in this code so it likely won't work.

To Reproduce

Steps to reproduce the behavior:

  1. Need to setup CanvasAPI to run a GraphQL call
  2. Will fill in more details later once it's tested but any call that returns more than 10 results (like all courses for a term) would likely only return the first page.

Expected behavior

Return a paginated list so the user can page through it.

Environment information

  • Python version 3.12
  • CanvasAPI version 3.3.0
@jonespm jonespm added the bug label Sep 27, 2024
@jsmnhou
Copy link
Contributor

jsmnhou commented Dec 2, 2024

I'd love to work on this issue!

@jonespm
Copy link
Contributor Author

jonespm commented Dec 6, 2024

Just moving this comment from the PR to provide more clarity on this issue.

GraphQL is a special separate API and actually has it's own way of doing pagination using the Relay Connection Spec as mentioned on this documentation. It adds new first/after arguments and It doesn't use response headers like the other API's. I was thinking that the code here could be a method like fetch_all_pages and programmatically inject these and make the call. I can add some more examples to the original issue.

So it would need completely new custom code somewhere to handle this, maybe something like a paginated_graphql_list.py or maybe just in util.

The graphql call is in canvas.py

def graphql(self, query, variables=None, **kwargs):
sends the request "as-is".

I'd expect code to detect and inject pagination into a GraphQL call might be more complicated than what is currently there for the regular API.

Hopefully there's a library or something to handle this as it seems like injecting pagination for nested connections might be a lot of code.

@jonespm jonespm changed the title GraphQL needs to be put in PaginatedList GraphQL needs to support pagination Dec 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants