Closed mschipperheyn closed 5 years ago
It's because you're using limit, there's no way around it as you're asking for 3 per postIds, grouping all the post ids and limits would not give the intended result.
@mickhansen I hear what you're saying. I'm wondering if there's any way I could customize this stuff for the intended result.
@mschipperheyn How would you express this in SQL? N of subgroup is a common SQL problem.
Perhaps some intermediary table or view with something like https://mobile.databasejournal.com/features/mysql/selecting-the-top-n-results-by-group-in-mysql.html
One Solution that Works: UNION with LIMIT
Is the solution sequelize went with, i think i wrote that code but it's probably been a few years :)
It's a tough problem unfortunetaly. In the graphql world you're sometimes better off not using limit
if you know the total amount of rows is a reasonable one.
I have the following domain objects
The Like type has a number of types based on it (not just post, but also course, etc)
I use the following resolver for Post
And this is the query I see:
it recurses for as many posts as there are. Seems very inefficient and not the intention of the dataloader.
What I would expect is a simple query retrieving all the likes based on
IN (...postIds)
and the graphql sorting out the assignment. Is there a better way I can do this?