StrawHat.GraphQL v0.2.2 StrawHat.GraphQL.MutationResponse View Source
Absinthe Mutation Response utilities. Normally will be use in Absinthe resolvers.
Usage
On the resolver.
Examples
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 Sourcemutation_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 Sourcefailed(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.
Link to this function
response_with(arg1)
View Sourceresponse_with({:ok, any()} | {:error, any()} | any()) ::
{:ok, mutation_response()} | no_return()
Returns a succeeded mutation response map.