You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
basket(slug: "grandma-basket") {
idfruits {
namecolor
}
parent {
id # We only ask for parent's id and no other field
}
}
...would make two queries like:
SELECT (...) FROM fruits_baskets WHERE slug ="grandma-basket"-- Get basketSELECT (...) FROM fruits_baskets WHERE id =42-- Get parent basket
The thing is that second query is not necessary: we already have the parent id in grandma's basket.
I think it is a very common pattern to query only for the id of an association. In this example, the request could be used to show a "Go to parent" link on the frontend.
My real use case is a comment system where comments can reply to each others by using a reply_to field. I would love to see assoc use the reply_to_id field instead of preloading the full reply_to when requesting only the id.
The easiest way to achieve this with actual system is to add a field for the id:
This is a duplicate of absinthe-graphql/dataloader#7. I'm not using dataloader anymore at the moment and figured out it has more of its place here.
Let's say I have a
:fruits_basket
object that can contains fruits and that can be placed in another basket. Something like:As of today a request like:
...would make two queries like:
The thing is that second query is not necessary: we already have the parent id in grandma's basket.
I think it is a very common pattern to query only for the id of an association. In this example, the request could be used to show a "Go to parent" link on the frontend.
My real use case is a comment system where comments can reply to each others by using a
reply_to
field. I would love to seeassoc
use thereply_to_id
field instead of preloading the fullreply_to
when requesting only the id.The easiest way to achieve this with actual system is to add a field for the id:
But that doesn't look very neat to me.
The text was updated successfully, but these errors were encountered: