We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 9f6a11e commit 0a826bdCopy full SHA for 0a826bd
lib/plate_slate_web/schema.ex
@@ -1,12 +1,26 @@
1
defmodule PlateSlateWeb.Schema do
2
use Absinthe.Schema
3
- # also see Absinthe.Schema.Notation
+
4
+ import Ecto.Query
5
+ alias PlateSlate.{Menu, Repo}
6
7
query do
8
field :menu_items, list_of(:menu_item) do
- resolve fn _, _, _ ->
- schema = PlateSlate.Menu.Item
9
- {:ok, PlateSlate.Repo.all(schema)}
+ arg :matching, :string
10
11
+ resolve fn
12
+ _, %{matching: term}, _ ->
13
+ items =
14
+ Menu.Item
15
+ |> where([i], ilike(i.name, ^"%#{term}%"))
16
+ |> Repo.all
17
+ {:ok, items}
18
19
+ _, _, _ ->
20
21
22
23
24
end
25
26
0 commit comments