Packages

Athena Event Logistics - Backend / Web

Current section

Files

Jump to
athena_logistics lib athena_web schema event resolver.ex
Raw

lib/athena_web/schema/event/resolver.ex

defmodule AthenaWeb.Schema.Event.Resolver do
@moduledoc false
use AthenaWeb, :resolver
alias Athena.Inventory
alias Athena.Inventory.Event
@spec event(parent :: term(), args :: map(), resolution :: Absinthe.Resolution.t()) ::
AthenaWeb.resolver_result()
def event(_parent, %{id: id}, _resolution), do: {:ok, Inventory.get_event!(id)}
@spec stock(parent :: Event.t(), args :: map(), resolution :: Absinthe.Resolution.t()) ::
AthenaWeb.resolver_result()
def stock(%Event{id: id}, args, _resolution) do
connection_from_query(
from(event in Inventory.stock_query(), where: event.id == ^id),
args,
&Repo.all/1,
nil
)
end
end