Convert two-sided relationship field in examples/blog to one-sided because of bad practice #7187
Replies: 3 comments 4 replies
-
You can always change the UI display mode for relationship field to be |
Beta Was this translation helpful? Give feedback.
-
And good alternative to |
Beta Was this translation helpful? Give feedback.
-
The Please see our tests for an example keystone/tests/api-tests/queries/limits.test.ts Lines 22 to 26 in 58f525d And the following for the implementation keystone/packages/core/src/lib/core/queries/resolvers.ts Lines 255 to 272 in 58f525d This is an example of where our examples could be more instructive for these nuanced problems. |
Beta Was this translation helpful? Give feedback.
-
Now in "examples/blog" project we have two-sided relationship between
Author
andPost
lists itemsTwo-sided relationship suites well for many cases, but if it comes to blog, this way of relationship leads to very bad performance, when blog accumulates a lot of posts from some author!
For example, if an author "alice" would create 1000 posts, the "Alice" item will contain 1000 items in "posts" field.
This will be very bad for performance, because the "Author" item is loaded very often, even for authorization process. Also when we trying to get list of authors, ids of all posts for each author will be loaded!
So I think that this is a very bad practice to give this for users as "perfect" example, and recommend conversion of two-sided relationship field to one-sided, to eliminate this bad practice when users creates their projects, based on this example. What do you think about this?
Beta Was this translation helpful? Give feedback.
All reactions