[Solved] Ash Framework B4: passing map instead of string in search_artists! (page 85)

Ash Framework B4: passing map instead of string in search_artists! (page 85)

Custom Actions with Arguments • 67

Hi! search_artists! accepts the first arg to be map afaik.

I tried this on iex shell:

Tunez.Music.search_artists!("rain")

Throws

** (Protocol.UndefinedError) protocol Enumerable not implemented for type BitString

Got value:

    "rain"

Here’s what i read in the book:

03/lib/tunez_web/live/artists/index_live.ex
def handle_params(params, _url, socket) do
  query_text = Map.get(params, "q", "")
  artists = Tunez.Music.search_artists!(query_text)
  socket =
    socket
    |> assign(:query_text, query_text)
    |> assign(:artists, artists)
# ...

So instead of using:

artists = Tunez.Music.search_artists!(query_text)

Should it be like this?

artists = Tunez.Music.search_artists!(%{query: query_text})