Skip to content
This repository has been archived by the owner on Feb 17, 2020. It is now read-only.

Commit

Permalink
Make option argument optional for generic crud resolvers
Browse files Browse the repository at this point in the history
  • Loading branch information
Marko Požega committed Jul 3, 2018
1 parent cd06dd4 commit c37a0d8
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/crudimentary/absinthe/resolvers/crud.ex
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ defmodule CRUDimentary.Absinthe.Resolvers.CRUD do
resolution :: map,
options :: keyword
) :: {:ok, %{data: map, pagination: ResultFormatter.pagination_result()}} | {:error, any}
def index(schema, current_account, _parent, args, _resolution, options) do
def index(schema, current_account, _parent, args, _resolution, options \\ []) do
with repo <- options[:repo] || @repo,
policy <- options[:policy] || policy_module(schema),
{:authorized, true} <- {:authorized, authorized?(policy, current_account, :index)} do
Expand Down Expand Up @@ -78,7 +78,7 @@ defmodule CRUDimentary.Absinthe.Resolvers.CRUD do
resolution :: map,
options :: keyword
) :: {:ok, %{data: map, pagination: ResultFormatter.pagination_result()}} | {:error, any}
def show(schema, current_account, _parent, args, _resolution, options) do
def show(schema, current_account, _parent, args, _resolution, options \\ []) do
with repo <- options[:repo] || @repo,
policy <- options[:policy] || policy_module(schema),
{:authorized, true} <- {:authorized, authorized?(policy, current_account, :show)},
Expand All @@ -104,7 +104,7 @@ defmodule CRUDimentary.Absinthe.Resolvers.CRUD do
resolution :: map,
options :: keyword
) :: {:ok, %{data: map}} | {:error, any}
def create(schema, current_account, _parent, args, _resolution, options) do
def create(schema, current_account, _parent, args, _resolution, options \\ []) do
with repo <- options[:repo] || @repo,
policy <- options[:policy] || policy_module(schema),
{:authorized, true} <- {:authorized, authorized?(policy, current_account, :create)},
Expand Down Expand Up @@ -139,7 +139,7 @@ defmodule CRUDimentary.Absinthe.Resolvers.CRUD do
resolution :: map,
options :: keyword
) :: {:ok, %{data: map, pagination: ResultFormatter.pagination_result()}} | {:error, any}
def update(schema, current_account, _parent, args, _resolution, options) do
def update(schema, current_account, _parent, args, _resolution, options \\ []) do
with repo <- options[:repo] || @repo,
{:resource, %schema{} = resource} <- {:resource, repo.get(schema, args[:id])},
policy <- options[:policy] || policy_module(schema),
Expand Down Expand Up @@ -174,7 +174,7 @@ defmodule CRUDimentary.Absinthe.Resolvers.CRUD do
resolution :: map,
options :: keyword
) :: {:ok, %{data: map}} | {:error, any}
def destroy(schema, current_account, _parent, args, _resolution, options) do
def destroy(schema, current_account, _parent, args, _resolution, options \\ []) do
with repo <- options[:repo] || @repo,
policy <- options[:policy] || policy_module(schema),
resource <- repo.get_by(schema, id: args[:id]),
Expand Down

0 comments on commit c37a0d8

Please sign in to comment.