Calculations in AshJsonApi?
Just want to make sure I'm not missing anything obvious - is it possible to include a calculation in a JsonApi request? Including one in the
includes
list seems to imply it's only looking for resources:
10 Replies
Oh! Looks like it works when adding it to
default_fields
. Though I also need to somehow include a calculation from a relationship. Please let me know if anyone has any insights there.
Ok, seems to just work if the default read on the relationship also loads the calculation in a preparation.Hmm...
That is definitely a bug
can you open an issue on
ash_json_api
oh,
you don't use includes
for that
you use fields
we should be validating that though
v
https://jsonapi.org/format/#fetching-sparse-fieldsets
you'd have to include all the fields you want in addition to the calculationSadly getting an error with the
fields=
param
I can make an issue after finishing up some things I need to get outfields[type]=...
You have to specify which type of thing you're setting the fields for
i.e /foos?fields[foo]=foo,bar,baz
Ah got it. Still coming up with an
InvalidField
code with field[type]=attr1,calculated
format. Even tried with a simple concat
-based calculation with the same result. I can try reproing in a simplified test later.๐ค that would be great ๐
๐โโ๏ธ thanks!
Hey, could you open this as a PR?
Sure, done! No rush of course. I might try fixing it myself in the same PR. I need to also show public calculated fields in the OpenAPI schema too