Handles configuration resolution and JavaScript initialization for the Altair GraphQL Client plug.
Any snake_case Elixir option key is automatically converted to its camelCase
JavaScript equivalent (e.g. :initial_query becomes initialQuery). This
means all Altair configuration properties
are supported — not just a hardcoded subset.
Configuration values can be static strings/maps or {module, function} tuples
that are resolved at request time. Functions may accept zero arguments or one
argument (the Plug.Conn).
Summary
Functions
Builds a JavaScript object literal string for AltairGraphQL.init().
Escapes a string for safe interpolation inside a JavaScript single-quoted string.
Resolves all dynamic configuration values and builds the template config map.
Resolves a configuration value. Static values pass through unchanged.
{module, function} tuples are called with the conn (arity 1) or without
arguments (arity 0).
Converts a snake_case atom to a camelCase string.
Functions
Builds a JavaScript object literal string for AltairGraphQL.init().
String values are escaped and quoted. Map values are JSON-encoded.
A nil endpoint_url produces an unquoted JS expression using window.location.
Nil/absent options are omitted.
Escapes a string for safe interpolation inside a JavaScript single-quoted string.
@spec resolve_options(map(), Plug.Conn.t()) :: map()
Resolves all dynamic configuration values and builds the template config map.
Returns a map with :base_url and :init_options_js keys ready for the
EEx template.
@spec resolve_value(term(), Plug.Conn.t()) :: term()
Resolves a configuration value. Static values pass through unchanged.
{module, function} tuples are called with the conn (arity 1) or without
arguments (arity 0).
Converts a snake_case atom to a camelCase string.
The special key :endpoint_url is converted to "endpointURL" to match
Altair's expected casing.
Examples
iex> AbsintheAltair.Config.to_js_key(:initial_query)
"initialQuery"
iex> AbsintheAltair.Config.to_js_key(:endpoint_url)
"endpointURL"