I have an Ash GraphQL schema, with calculations, simplified like so:
attributes do
attribute :start_at, :utc_datetime, public?: true
end
calculations do
calculate :end_at,
:utc_datetime,
expr(datetime_add(start_at, duration, :millisecond)),
public?: true
end
end
graphql do
queries do
get :get_event, :read
end
end
The issue is that the calculated end_at
attribute is not loaded when performing the query. The start_at
attribute, of course, loads fine since it is an actual db column.
query GetEvent($id: ID!) {
getEvent(id: $id) {
startAt
endAt
}
}
=> end_at = #Ash.NotLoaded<:calculation, field: :end_at>
How can I load or resolve a calculated Ash attribute with Ash Graphql? I wasn’t able to find anything about calculations in AshGraphql documentation, nor anything about graphql in Ash documentation