Closed Eraldo closed 5 months ago
This pull request introduces an MPTT (Modified Preorder Tree Traversal) relation to the RelayAuthor model to address an issue where querying for an author and their children would break if no children were present. The changes include modifying the RelayAuthor model to inherit from MPTTModel, adding a parent field to establish the tree structure, and updating the AuthorType to include a children connection. A new test file, test_nested_children.py, is added to illustrate the issue and verify the fix.
Files | Changes |
---|---|
tests/relay/lazy/models.py tests/relay/lazy/a.py |
Updated the RelayAuthor model to support MPTT relations and modified the AuthorType to include a children connection. |
tests/relay/lazy/test_nested_children.py |
Added a new test file to verify the fix for querying authors and their children. |
Closing this as https://github.com/strawberry-graphql/strawberry-django/pull/553 superseded it
Description
Trying to get an author and then the total count of the children of that author breaks when there are no children present but requested in the query. Error:
The PR includes a test
test_nexted_children.py
, which illustrates the use case and resulting error.FYI: Disabling the
DjangoOptimizerExtension
makes the test pass without any issue.Types of Changes
Summary by Sourcery
This pull request enhances the RelayAuthor model by adding MPTT relations to support hierarchical data structures. Additionally, a new test case is introduced to verify the nested children count functionality.