-
-
Notifications
You must be signed in to change notification settings - Fork 536
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
feat(relay): Allow to customize max_results per connection in relay #3746
base: main
Are you sure you want to change the base?
Conversation
Reviewer's Guide by SourceryThis pull request introduces a new feature that allows developers to customize the maximum number of results returned per connection in a Relay schema. This is achieved by adding a Sequence diagram for relay connection resolution with max_resultssequenceDiagram
participant Client
participant Connection
participant ConnectionExtension
participant ListConnection
Client->>Connection: Query with connection field
Connection->>ConnectionExtension: resolve()
Note over ConnectionExtension: Check max_results parameter
ConnectionExtension->>ListConnection: resolve_connection(max_results)
Note over ListConnection: Apply max_results limit
ListConnection-->>ConnectionExtension: Limited results
ConnectionExtension-->>Connection: Connection with paginated data
Connection-->>Client: Final response
Class diagram showing the updated ConnectionExtension and connection field changesclassDiagram
class ConnectionExtension {
+connection_type: type[Connection[Node]]
+max_results: Optional[int]
+__init__(max_results: Optional[int])
+apply(field: StrawberryField)
+resolve(...)
+resolve_async(...)
}
class connection {
<<function>>
+__call__(..., max_results: Optional[int])
}
note for ConnectionExtension "New max_results parameter
to override default limit"
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @bellini666 - I've reviewed your changes - here's some feedback:
Overall Comments:
- There's a typo in the documentation examples where 'strawberry' is misspelled as 'strawerry'
Here's what I looked at during the review
- 🟡 General issues: 1 issue found
- 🟢 Security: all looks good
- 🟡 Testing: 2 issues found
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
docs/guides/relay.md
Outdated
class Query: | ||
fruits: ListConnection[Fruit] = relay.connection(max_results=10_000) | ||
``` | ||
|
||
### Custom connection pagination | ||
|
||
The default `relay.Connection` class don't implement any pagination logic, and |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue (typo): Typo: "don't" should be "doesn't"
The sentence should read "The default relay.Connection
class doesn't implement any pagination logic..."
Thanks for adding the Here's a preview of the changelog: Add the ability to override the "max results" a relay's connection can return on The default value for this is defined in the schema's config, and set to For example: @strawerry.type
class Query:
# This will still use the default value in the schema's config
fruits: ListConnection[Fruit] = relay.connection()
# This will reduce the maximum number of results to 10
limited_fruits: ListConnection[Fruit] = relay.connection(max_results=10)
# This will increase the maximum number of results to 10
higher_limited_fruits: ListConnection[Fruit] = relay.connection(max_results=10_000) Note that this only affects Here's the tweet text:
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #3746 +/- ##
=======================================
Coverage 97.28% 97.28%
=======================================
Files 502 502
Lines 33375 33395 +20
Branches 5477 5482 +5
=======================================
+ Hits 32469 32489 +20
Misses 697 697
Partials 209 209 |
CodSpeed Performance ReportMerging #3746 will not alter performanceComparing Summary
|
# This will increase the maximum number of results to 10 | ||
higher_limited_fruits: ListConnection[Fruit] = relay.connection(max_results=10_000) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a typo, right?
# This will increase the maximum number of results to 10 | |
higher_limited_fruits: ListConnection[Fruit] = relay.connection(max_results=10_000) | |
# This will increase the maximum number of results to 10000 | |
higher_limited_fruits: ListConnection[Fruit] = relay.connection(max_results=10_000) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Straightforward implementation and well-tested :)
Fix #3734
Summary by Sourcery
New Features:
max_results
parameter to the@connection
decorator to customize the maximum number of results per connection field, overriding the global schema setting.