Huh, indeed! Fields are not included in path. However, looks like we can dig that info out from the resolution struct! (metadata.resolution.definition.selections
is a list of fields requested to be resolved)
Don’t know if this is the most optimal way, but seems to be doing the trick:
:telemetry.attach(
:resolved_paths,
[:absinthe, :resolve, :field, :stop],
fn _event_name, _measurements, metadata, _config ->
Absinthe.Resolution.path(metadata.resolution)
|> IO.inspect(label: "RESOLUTION PATH")
# THIS
# metadata.resolution.definition.selections
Absinthe.Resolution.project(metadata.resolution)
|> Enum.map(fn field -> field.name end)
|> IO.inspect(label: "SELECTED FIELDS")
end,
[]
)
I guess it would print something like:
RESOLUTION PATH: ["user"]
SELECTED FIELDS: ["info"]
...
RESOLUTION PATH: ["user", "info"]
SELECTED FIELDS: ["age", "color"]
UPD looks like we could use Absinthe.Resolution.project/1
Get the child fields under the current field.
so we could replace metadata.resolution.definition.selections
with
Absinthe.Resolution.project(metadata.resolution)
And probably that would be better approach, because that way we delegate “dealing with the internal structure of the resolution struct” to the function.