Skip to content

Commit

Permalink
Improve documentation + release 0.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Nickforall committed Sep 15, 2018
1 parent 245a754 commit 51a8116
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 2 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
# Changelog
## 0.1.1
## 0.2.0

**Added:**
* Ecto integration, which generates error messages from failed changesets
* Errors array is no longer nullable, and now always returns an array
* Errors are now an object instead of a string
* Successful field is no longer nullable
* Configurable error objects in the errors array using application env
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@ Freight is a library for [Absinthe GraphQL](http://absinthe-graphql.org/) that h

It is heavily inspired by [Kronky](https://github.com/Ethelo/kronky), I decided to build my own library because I did not like how much it is focussed on ecto changesets, and missed customisability that was required for a project I work on.

## Configuration

You can set a custom error object that will be returned in the errors array in your payloads. This object must be defined in the schemna you're calling `define_payload` from.

```elixir
config :freight,
error_object: :user_error
```

## Usage

Below is a documented example of how to define Freight payloads in your schema
Expand Down
6 changes: 6 additions & 0 deletions lib/error_payload.ex
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
defmodule Freight.Payload.ErrorPayload do
alias Freight.Integrations

@moduledoc """
Error payloads are payloads that are created when an :error tuple has been returned.
Their `successful` property is always set to `false`.
"""

@doc """
Manually generates a map representing a generic unsuccessful object.
All customized result fields will not be defined, and thus returned as nil
Expand Down
6 changes: 6 additions & 0 deletions lib/success_payload.ex
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
defmodule Freight.Payload.SuccessPayload do
@moduledoc """
Success payloads are payloads that are created when an :ok tuple has been returned.
Their `successful` property is always set to `true`.
"""

@base_success_payload %{
successful: true,
errors: []
Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ defmodule Freight.MixProject do
def project do
[
app: :freight,
version: "0.1.0",
version: "0.2.0",
elixir: "~> 1.6",
start_permanent: Mix.env() == :prod,
deps: deps(),
Expand Down

0 comments on commit 51a8116

Please sign in to comment.