In my Abinsthe schema, I have a field resolver which creates an AWS signed link. The problem with this approach is that I can’t reuse it elsewhere. For example, I need that url field when I query the data via Ecto to store that json data in S3. I suspect it’s a combination between virtual fields, computed fields, and using the Jason encoder, but I am not really sure how all those tie together. Could someone help me with this?
For example, my schema is like so:
@derive {
Jason.Encoder,
only: [
:name,
:last_modified,
:size,
:mime_type
]
}
embedded_schema do
field :name, :string
field :last_modified, :naive_datetime
field :size, :integer
field :mime_type, :string
end
I then query everything and preload everything before running it through Jason.encode!
. How can I have Jason.encode create a url field which computes a signed url?