neuron v0.9.0 Neuron View Source

Neuron is a GraphQL client for elixir.

Usage

iex> Neuron.Config.set(url: "https://example.com/graph")
iex> Neuron.Config.set(headers: [hackney: [basic_auth: {"username", "password"}]])

iex> Neuron.query("""
    {
      films {
        title
      }
    }
    """)

# Response will be:
{:ok, %Neuron.Response{body: %{"data" => {"films" => [%{"title" => "A New Hope"}]}}%, status_code: 200, headers: []}}

# You can also run mutations
iex> Neuron.mutation("YourMutation()")

Link to this section Summary

Functions

runs a mutation request to your graphql endpoint

runs a query request to your graphql endpoint

Link to this section Functions

Link to this function mutation(mutation_string, options \\ []) View Source
mutation(query_string :: String.t(), options :: keyword()) ::
  Neuron.Response.t()

runs a mutation request to your graphql endpoint

Example

Neuron.mutation("YourMutation()")

You can also overwrite parameters set on Neuron.Config by passing them as options.

Example

Neuron.mutation("YourMutation()", url: "https://api.super.com/graph")
Link to this function query(query_string, options \\ []) View Source
query(query_string :: String.t(), options :: keyword()) :: Neuron.Response.t()

runs a query request to your graphql endpoint.

Example

Neuron.query("""
  {
    films {
      title
    }
  }
""")

You can also overwrite parameters set on Neuron.Config by passing them as options.

Example

Neuron.query(
  """
  {
    films {
      title
    }
  }
  """,
  url: "https://api.super.com/graph"
)