StrawHat.GraphQL v0.1.2 StrawHat.GraphQL.MutationResponse View Source
Absinthe Mutation Response utilities. Normally will be use in Absinthe resolvers.
Usage
On the resolver.
defmodule App.AccountResolver do
alias StrawHat.GraphQL.MutationResponse
def create_account(params, _) do
case App.Account.create_account(params) do
{:ok, account} -> MutationResponse.succeeded(account)
{:error, reason} -> MutationResponse.failed(reason)
end
end
end
Link to this section Summary
Types
successful
: When the mutation succeeded or not.payload
: Data of the mutation payload.errors
: List ofStrawHat.Error.t/0
Link to this section Types
Link to this type
mutation_response()
View Source
mutation_response() :: %{ successful: boolean(), payload: any(), errors: [StrawHat.Error.t()] }
successful
: When the mutation succeeded or not.payload
: Data of the mutation payload.errors
: List ofStrawHat.Error.t/0
.
Link to this section Functions
Link to this function
failed(changeset)
View Source
failed(Ecto.Changeset.t()) :: {:ok, mutation_response()}
failed(StrawHat.Error.t()) :: {:ok, mutation_response()}
failed(StrawHat.Error.ErrorList.t()) :: {:ok, mutation_response()}
failed(any()) :: no_return()
Returns a failed mutation response map.
Returns a succeeded mutation response map.