The idea here is to add a metadata option to each route that allows users to control the top-level meta of that route:
routes do
index :read do
metadata fn query, results, request ->
%{"my" => "custom", "metadata" => "here"}
end
end
end
would result in
{
"data": <...>,
"links": [<...>],
"meta": {
"my": "custom",
"metadata": "here",
<...any builtin metadata such as page metadata>
}
}
The main part of this PR that I'm a little unsure on is how I'm grabbing the query/changeset in helpers.ex. It seems like each route type has its own somewhat complex custom logic in there, and I'm not 100% sure that I've gotten the correct query/changeset in each scenario. This is my first substantive contribution here so I'm very open to feedback, I'm sure there's things to improve on here!
Contributor checklist
👋🏻
Coming from Discord, thread
The idea here is to add a
metadata
option to each route that allows users to control the top-level meta of that route:would result in
The main part of this PR that I'm a little unsure on is how I'm grabbing the query/changeset in
helpers.ex
. It seems like each route type has its own somewhat complex custom logic in there, and I'm not 100% sure that I've gotten the correct query/changeset in each scenario. This is my first substantive contribution here so I'm very open to feedback, I'm sure there's things to improve on here!