Skip to content

Commit

Permalink
Merge branch 'hotfix/add-encode-func'
Browse files Browse the repository at this point in the history
  • Loading branch information
hadfieldn committed Jan 26, 2019
2 parents 4ac5304 + 26f720e commit a76710f
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lib/absinthe_sorting_codec.ex
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,18 @@ defmodule AbsintheSortingCodec do
Uses [Jason](https://github.com/michalmuskala/jason) for encoding into JSON.
"""
def encode!(schema, opts \\ []) do

def encode(schema, opts \\ []) do
schema
|> sorted_objects()
|> Jason.encode!(opts)
|> Jason.encode(opts)
end

def encode!(schema, opts \\ []) do
case encode(schema, opts) do
{:ok, content} -> content
{:error, reason} -> raise reason
end
end

defp sorted_objects(value)
Expand Down

0 comments on commit a76710f

Please sign in to comment.