How do you go about using dataloader when the parent field returns a map instead of struct. In my case the parent field (block) doesn’t map cleanly to one single table so I have to grab fields from a number of tables and create a map with the fields I need to return. Unfortunately this completely breaks dataloader which relies on the associations in a struct.
object :block do field :author, :user, resolve: dataloader(Scribe.Accounts, :user) end
My current fix is to create a custom resolver for the author, i.e. don’t use dataloader (this is obviously not ideal)
object :block do field :author, :user do resolve(&ScribeWeb.Resolvers.Accounts.get_user/3) end end
Does anyone know how to still use dataloader in this situation? Only things I can think of are to using a custom run_batch implementation (don’t understand this nearly well enough to attempt it) or use an embedded schema for the block (this is a wild guess, I’ve never used an embedded schema before).
Thanks in advance for the help!