absinthe-graphql/absinthe_relay

Absinthe.Resolution.project/1 for child fields

allenwyma opened this issue · 3 comments

Hi, I ran into an issue where I wanted to selectively apply some joins based on if some child fields were included within the top level query of an edge's node (I think that's the proper term/order?)

I have a field like so:

widget {
edges {
  node {
    id
    name
    sumOfChildData
  }
 }
}

It would be great if I can somehow check for the sumOfChildData from the resolution to see what fields from my node is required, then I can selectively query for the data.

Something similar is the Absinthe.Resolution.project/1 but that will only give me edges and pageInfo.

Hey @HangingClowns the general solution here is to recursively call project on the fields returned from your initial project. Do note that if you end up using abstract types this may get challenging to do in the general case.

Hi @benwilson512 ! Thanks for the reply, so you mean I would do:

resolution |> project() |> project() |> project()

?

Hey @HangingClowns do you mind asking this on the forums? The issue tracker is really aimed at issues or bugs, not general questions. The forum has better long term visibility.