florid-sojourner
How do I filter an action by multiple arguments but allow one or more of the arguments to be nil, and in those cases, drop that filter clause?
In other words, with what I’ve written, all the arguments are needed or no results are returned.
localhost:4000/api/flows?inlclude=project&include=phase&include=flow_phase&owned_by=guild&status=active&phase_status=current
returns results, but
localhost:4000/api/flows?inlclude=project&include=phase&include=flow_phase&owned_by=guild&status=active
returns nothing. My desire is that it would have returned MORE results.
I’m relatively new to both Ash and Elixir, so please forgive me if the answer should be obvious.
Here’s my action:
actions do
defaults [:create]
read :read do
primary? true
prepare(build(load: [:project]))
argument :status, :atom do
allow_nil? true
end
argument :owned_by, :atom do
allow_nil? true
end
argument :phase_status, :atom do
allow_nil? true
end
filter expr(
status == ^arg(:status) and flow_phase.status == (^arg(:phase_status)) and
flow_phase.phase.owned_by == ^arg(:owned_by)
)
end
end
Trending in Questions
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
Hello!
Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app.
I creat...
New
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
So my question is quite simple and i have found no conclusive answer on forum, google or AI.
Should we use :erlang.float for Integer to ...
New
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New
Hello,
I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
Other Trending Topics
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve.
They are GUI (Emerge) and State management (S...
New
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #ai
- #elixirconf-us
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming











Showing Posts 1 to 5- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
zachdaniel
This can be done in the expression with a statement like
With that said, if you’re using ash_json_api, a filter can already be provided as part of the api, so I’d suggest using that vs hand rolling your own filter interface
florid-sojourner
Thanks!
I would love to use the Ash JSON API filtering. I can get a basic filter to work, but not a filter through a relationship.
The JSON API documentation says that the spec is agnostic about the filtering strategy implemented by a server. JSON:API — Recommendations Is there a clear set of documentation for filtering using Ash JSON API? I’m struggling to locate any.
zachdaniel
Unfortunately I don’t think we have a detailed documentation of the filter format. With that said, you can filter through relationships like so
filter=relationship[field][eq]=10, for example. This spec is well formed for this, just not well documented. What I would really like to do is properly create the json schema for a filter, in the same way we properly type out the filter type forash_graphql(users of which don’t have this problem since the whole thing is typed).florid-sojourner
I’m participating in evaluating Ash in an active project at my organization and I’m hopeful we can adopt it. The documentation situation is unfortunate but I also understand. Your time is limited.
I’m using this query:
localhost:4000/api/flows?inlclude=project&include=phase&include=flow_phase&filter=flow_phase[status][eq]=current
And getting this error:
{
“errors”: [
{
“code”: “FrameworkError”,
“id”: “bf898af0-17ee-4fe3-9325-bdfc57d1ad0f”,
“status”: “500”,
“title”: “Framework Error”,
“detail”: “Returned when an unexpected error in the framework has occurred.”
},
{
“code”: “InvalidQuery”,
“id”: “1588e20a-e946-4eb7-ae50-0f28f45ab121”,
“status”: “400”,
“title”: “Invalid Query”,
“source”: {
“parameter”: “filter”
},
“detail”: “Expected "object", got "flow_phase[status][eq]=current", at ["filter"].”
}
],
“jsonapi”: {
“version”: “1.0”
}
}
zachdaniel
Sorry, my previous post had a typo
filter[flow_phase][status][eq]=currentwould be the correct way to do it.