Packages

A grab bag of utilities I tend to want, so I can build faster.

Current section

Files

Jump to
fast lib absinthe operation_name_logger.ex
Raw

lib/absinthe/operation_name_logger.ex

defmodule Fast.Absinthe.OperationNameLogger do
@behaviour Absinthe.Middleware
alias Absinthe.Blueprint.Document.Operation
def call(resolution, _opts) do
case Enum.find(resolution.path, &current_operation?/1) do
%Operation{name: name} when not is_nil(name) ->
Logger.metadata(graphql_operation_name: name)
_ ->
Logger.metadata(graphql_operation_name: "#NULL")
end
resolution
end
defp current_operation?(%Operation{current: true}), do: true
defp current_operation?(_), do: false
end