AshGraphql.Plugin.ResponseMetadata (ash_graphql v1.10.0)

Copy Markdown View Source

Absinthe plugin that captures timing information and injects response metadata.

Usage

Add this plugin to your schema:

defmodule MyApp.Schema do
  use Absinthe.Schema
  use AshGraphql, domains: [...], response_metadata: true

  def plugins do
    [AshGraphql.Plugin.ResponseMetadata | Absinthe.Plugin.defaults()]
  end
end

Summary

Functions

Records end time for duration calculation.

Records start time for duration calculation.

Conditionally adds the metadata injection phase to the pipeline.

Functions

after_resolution(execution)

Records end time for duration calculation.

Stores System.monotonic_time() in execution.acc[:ash_graphql][:end_time]. Always overwrites (captures the latest resolution end).

before_resolution(execution)

Records start time for duration calculation.

Stores System.monotonic_time() in execution.acc[:ash_graphql][:start_time]. Only sets the value if not already present (idempotent).

pipeline(pipeline, execution)

Conditionally adds the metadata injection phase to the pipeline.

If the schema has response_metadata enabled, prepends AshGraphql.Phase.InjectMetadata to process the captured timing data.