Closed tlvenn closed 7 years ago
@benwilson512 friendly reminder I need your inputs to continue on this PR. Many thanks in advance.
@benwilson512 any chance you can jumpn in plz ?
This is really great, thank you!
a bit of an ecto noob here but I'm trying to join to filter on an associated table field sm.state_id
working with this PR. It doesn't seem to work though
field :applications, list_of(:application), resolve: assoc(:applications, fn query, _, _ ->
query
|> join(:inner, [app], sm in assoc(app, :sm))
|> where([_, sm], sm.state_id < 2800)
end)
I get this
web/schema/types.ex:109: undefined function app/0
did you import Ecto.Query
earlier in that module?
Ah, that was it! I was doing only importing join and where. Thanks yet again!
This implements
assoc/2
so that you can pass an optional function to further filter / order the query:ctx is the Absinthe context, i find it useful to map on to the logged user id and the like to contextualize some fields for the current user:
@benwilson512 let me know if this looks ok, I will need some guidance on how to best deal with default value for the query_fun and the macro/fun
assoc
.I also need to add proper documentation.