Tapper Absinthe Plug v0.2.1 Tapper.Absinthe.Helper View Source

Support functions for using Tapper in Absinthe.

Link to this section Summary

Functions

Wrap a resolver function call in span

Link to this section Types

Link to this type resolver_ret() View Source
resolver_ret() :: {:ok, any()} | {:error, any()}

Link to this section Functions

Link to this function in_span(info, fun) View Source
in_span(info :: Absinthe.Resolution.t(), fun :: (Tapper.Id.t() -> resolver_ret())) :: resolver_ret()

Wrap a resolver function call in span.

e.g.

import Tapper.Absinthe.Helper, only: [in_span: 2]

query do
  @desc "Get a Thing by UUID"
  field :thing, type: :thing do
    @desc "A Thing UUID"
    arg :id, non_null(:id)
    resolve fn(%{id: thing_id}, info) ->

      in_span(info, fn(tapper_id) ->
        # call real resolver function, passing %Tapper.Id{} etc.
        MyApp.ThingResolver.thing(thing_id, tapper_id)
      end)

    end
  end
end