Craft GraphQL APIs in Elixir with Absinthe Part Five

I am now onto the mutations chapter.

It seems that Decimal has changed it’s parse return. It used to be {:ok, decimal} but is now {decimal, remainder} which means that you will need the following to get Chapter 5 to build:

  scalar :decimal do
    parse fn
      %{value: value}, _ ->
        {d,_} = Decimal.parse(value)
        {:ok, d}
      _, _ ->
        :error
    end
    serialize &to_string/1
  end

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s