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

add pagination guide #1345

Merged
merged 98 commits into from
Jan 13, 2023
Merged

add pagination guide #1345

merged 98 commits into from
Jan 13, 2023

Conversation

aryaniyaps
Copy link
Contributor

@aryaniyaps aryaniyaps commented Oct 13, 2021

This PR adds a guide on how to implement pagination in GraphQL

Description

This PR adds a guide on how to implement pagination in GraphQL. It discusses about the common ways we would do pagination (whether GraphQL is involved or not), like cursor-based or offset-based pagination before implementing the same in GraphQL.

  • added general pagination guide
  • added offset pagination implementation
  • added cursor pagination implementation
  • merged relay connection docs by @Ambro17

Types of Changes

  • Core
  • Bugfix
  • New feature
  • Enhancement/optimization
  • Documentation

Issues Fixed or Closed by This PR

Checklist

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • I have tested the changes and verified that they work and don't break anything (as well as I can manage).

@aryaniyaps aryaniyaps marked this pull request as draft October 13, 2021 06:27
@codecov
Copy link

codecov bot commented Oct 13, 2021

Codecov Report

Merging #1345 (9e87914) into main (7321a43) will increase coverage by 1.31%.
The diff coverage is 100.00%.

❗ Current head 9e87914 differs from pull request most recent head 80f648c. Consider uploading reports for the commit 80f648c to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1345      +/-   ##
==========================================
+ Coverage   96.75%   98.07%   +1.31%     
==========================================
  Files         181      107      -74     
  Lines        7432     3842    -3590     
  Branches     1343      562     -781     
==========================================
- Hits         7191     3768    -3423     
+ Misses        144       41     -103     
+ Partials       97       33      -64     

docs/guides/pagination.md Outdated Show resolved Hide resolved
@strawberry-graphql strawberry-graphql deleted a comment from botberry Oct 13, 2021
Copy link
Member

@BryceBeagle BryceBeagle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this looks go to me, other than the request change for strings 👍
Assuming that's changed, I'll let @patrick91 give the final sign off

docs/README.md Outdated Show resolved Hide resolved
@aryaniyaps
Copy link
Contributor Author

I have hopefully responded to/ changed things as requested by code reviews. So, I assume the only other thing to do here is to make a final review/ merge, or suggest changes. pinging @patrick91 to do the same!

@fescobar
Copy link

Is there any problem with this PR being merged?

@patrick91
Copy link
Member

@aryaniyaps apologies for letting this PR get so old! I'll review it today 😊

Copy link
Member

@patrick91 patrick91 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is awesome! Sorry again for letting it sit for so long!

@patrick91 patrick91 merged commit 28708d8 into strawberry-graphql:main Jan 13, 2023
@soraia653
Copy link
Contributor

Hello everyone, I tried to implement the cursor pagination, but it's not working.

@patrick91
Copy link
Member

Hello everyone, I tried to implement the cursor pagination, but it's not working.

can you post an issue with what you've tried and what error you get?

@soraia653
Copy link
Contributor

soraia653 commented Feb 17, 2023

@patrick91
If you just directly copy + paste the code for the Cursor Pagination it results in several errors. I tried fixing a few, for example:

  • filtered_data = map(lambda user: user.id > user_id, user_data) -> 'id' is not an attribute, so I replaced with user['id'].

  • Also, since we are using map I get the error that a map function is not subscriptable.

  • UserType is not defined.

  • id field not defined in User class.

This is just some of the errors I found, please do let me know if I'm missing any information on how to properly apply the cursors. It's my first time using Strawberry and I'm loving it 🍓

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants