Neuron.Config (neuron v5.0.0) View Source

This module can be used to modify your graphql client configuration either globaly or for the current process.

Link to this section Summary

Functions

gets configuration value for Neuron

sets global configuration values for Neuron

sets global/process configuration values for Neuron

Link to this section Functions

Specs

get(config :: atom()) :: any()

gets configuration value for Neuron

Examples

iex>Neuron.Config.set(url: "http://example.com/graph")
iex>Neuron.Config.get(:url)
"http://example.com/graph"

iex>Neuron.Config.set(headers: [name: "value"])
iex>Neuron.Config.get(:headers)
[name: "value"]

iex>Neuron.Config.get(:invalid)
nil

Specs

set(value :: keyword()) :: :ok

sets global configuration values for Neuron

Examples

iex> Neuron.Config.set(url: "http://example.com/graph")
:ok

Specs

set(context :: :global | :process, value :: keyword()) :: :ok

sets global/process configuration values for Neuron

Available options are:

  • url: graphql endpoint url
  • headers: headers to be sent in the request
  • connection_opts: additional options to be passed to connection library
  • connection_module: module to be used for connecting to GQL API. Default is Neuron.Connection.Http
  • json_library: JSON library. Default is Jason.
  • parse_options: options to be passed to the JSON library when decoding JSON

Examples

iex> Neuron.Config.set(headers: [name: "val"])
:ok

iex> Neuron.Config.set(:process, url: "http://example.com/graph")
:ok

iex> Neuron.Config.set(json_library: Jason)
:ok

iex> Neuron.Config.set(parse_options: [keys: :atoms])
:ok