-
-
Notifications
You must be signed in to change notification settings - Fork 533
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 support for optional connections #3707
base: main
Are you sure you want to change the base?
Conversation
Enable nullable Connection types in the connection field decorator by updating type checking logic and adding validation for inner types. Update documentation and add tests to ensure compatibility with permission extensions and different nullable syntax. New Features: - Support nullable Connection types in the connection field decorator in strawberry.relay.fields. Enhancements: - Update type checking logic to handle Optional[Connection[T]] and Connection[T] | None annotations. Documentation: - Update documentation to reflect that connection fields can now be nullable. Tests: - Add tests to verify nullable connection fields work correctly with permission extensions and both Optional[Connection[T]] and Connection[T] | None syntax. Resolves #3703
for more information, see https://pre-commit.ci
Reviewer's Guide by SourceryThis PR adds support for nullable (optional) Connection types in Strawberry's relay field decorator. The implementation modifies the type handling in the relay fields to properly handle Optional Connection types and includes test cases to verify the functionality. Class diagram for updated relay field decoratorclassDiagram
class StrawberryField {
+apply(field: StrawberryField) void
+resolve() void
+connection_type: Type[Connection[Node]]
}
class Connection {
<<interface>>
}
class Node {
<<interface>>
}
class StrawberryOptional {
+of_type: Type
}
class ConnectionGraphQLType {
<<alias>>
}
StrawberryField --> Connection
StrawberryField --> Node
StrawberryField --> StrawberryOptional
StrawberryField --> ConnectionGraphQLType
note for ConnectionGraphQLType "Alias for handling optional Connection types"
Class diagram for new test casesclassDiagram
class User {
+id: NodeID
+name: str
+resolve_nodes(info, node_ids, required) List[User]
}
class UserConnection {
+resolve_connection(nodes: Iterable[User], info, after, before, first, last) Optional[Self]
}
class TestPermission {
+message: str
+has_permission(source, info, **kwargs) bool
}
UserConnection --> User
TestPermission --> UserConnection
note for User "Represents a user node in the relay connection"
note for UserConnection "Handles the connection logic for User nodes"
note for TestPermission "Custom permission class for testing"
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
CodSpeed Performance ReportMerging #3707 will not alter performanceComparing Summary
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3707 +/- ##
===========================================
- Coverage 96.70% 63.13% -33.58%
===========================================
Files 500 496 -4
Lines 33438 32339 -1099
Branches 5590 1663 -3927
===========================================
- Hits 32336 20417 -11919
- Misses 882 11589 +10707
- Partials 220 333 +113
|
Closes #3703