Use with Dataloader?
Un3qual opened this issue · 7 comments
How would I used Dataloader with absinthe_relay. Specifically, without dataloader
I might return
Post
|> Connection.from_query(
&(&1
|> Query.join_user_and_group
|> Query.preload_user_and_group
|> Query.only_posts_in_users_groups(user)
|> Repo.all
),
pagination_args,
PostUtils.sort_to_order(pagination_args.sort),
&PostUtils.order_to_where/3
)
But with dataloader
I need to return a Dataloader.load_many
or Dataloader.load
, but if I do that, it will not be formatted as relay requires with nodes
, edges
, cursors
, etc.
(note: Connection.from_query
is modified from the one provided by absinthe_relay
hence the extra arguments)
Whoops. Just found out about on_load
.
Hi @Un3qual
How you solve this problem? Connection.from_query
wants a query, but on_load
has already loaded data.
Hi @Un3qual
I would be interested to know more about how you approached this too !
There is not any way to use dataloader with relay from connection at this time, for the same reason that it wasn't possible with absinthe_ecto. The only way to generate sensible SQL is via a window fu function or lateral joins, neither of which are well supported by Ecto yet.
@benwilson512 is right. I had to fork both dataloader
and absinthe_relay
and do some really hacky stuff and even then, I abandoned it because it's a major PITA.
Is there an Ecto issue we can link to here for people? This is going to be a recurring question until it’s addressed there.
@benwilson512 The PR implementing a WINDOW function has been merged in Ecto. Would it make sense to reopen this issue?