View Source BridgeEx.Graphql.Client (bridge_ex v2.2.0)

Graphql client for BridgeEx.

Link to this section Summary

Functions

Calls a GraphQL endpoint

Link to this section Types

@type bridge_response() ::
  {:ok, term()}
  | {:error, {:bad_response, integer()}}
  | {:error, {:http_error, String.t()}}
  | {:error, list()}

Link to this section Functions

Link to this function

call(url, query, variables, opts)

View Source
@spec call(
  url :: String.t(),
  query :: String.t(),
  variables :: map(),
  opts :: Keyword.t()
) :: bridge_response()

Calls a GraphQL endpoint

parameters

Parameters

  • url: URL of the endpoint.
  • query: Graphql query or mutation.
  • variables: variables for Graphql query or mutation.
  • opts: various options.

options

Options

  • options: extra HTTP options to be passed to Telepoison.
  • headers: extra HTTP headers.
  • encode_variables: whether to JSON encode variables or not.
  • decode_keys: how JSON keys in GraphQL responses are decoded. Can be set to :strings (recommended), :atoms (discouraged due to security concerns - currently the default, but will be changed to :strings in a future version) or :existing_atoms (safer, but may crash the application if an unexpected key is received)
  • retry_options: configures retry attempts. Takes the form of [max_retries: 1, timing: :exponential]
  • log_options: configures logging on errors. Takes the form of [log_query_on_error: false, log_response_on_error: false].