Blunder.Absinthe v1.4.0 Blunder.Absinthe View Source

Helpers for Absinthe Integration

Link to this section Summary

Functions

This function takes an Absinthe middleware stack and adds error handling. Each middleware will be wrapped in a &Blunder.trap_exceptions/2 call and Blunder.Absinthe.ErrorProcessingMiddleware appended to the end of the stack to handle those and any other errors. By default only the resolvers for root queries & mutations are wrapped with the error handling. To wrap all resolvers and stop errors deeper in the tree instead of letting them bubble up tp the root, add wrap_all_resolvers: true to the options

Link to this section Functions

Link to this function add_error_handling(middleware, field, opts \\ []) View Source
add_error_handling(
  [Absinthe.Middleware.spec(), ...],
  any(),
  opts :: [{:timeout_ms, number()}]
) :: [Absinthe.Middleware.spec(), ...]

This function takes an Absinthe middleware stack and adds error handling. Each middleware will be wrapped in a &Blunder.trap_exceptions/2 call and Blunder.Absinthe.ErrorProcessingMiddleware appended to the end of the stack to handle those and any other errors. By default only the resolvers for root queries & mutations are wrapped with the error handling. To wrap all resolvers and stop errors deeper in the tree instead of letting them bubble up tp the root, add wrap_all_resolvers: true to the options.

Call it in your Schema in your &middleware/3 callback like this:

  def middleware(middleware, field, _object) do
    Blunder.Absinthe.add_error_handling(middleware, field, timeout_ms: 3_000)
  end