View Source BridgeEx.Graphql (bridge_ex v2.1.0)

Create a Graphql bridge in the given module.

Once created, a graphql request can be made via MyBridge.call("my-query", %{"variable": "var"})

options

Options

  • endpoint (required): URL of the remote Graphql endpoint.
  • auth0: enable and configure Auth0 for authentication of requests. Takes the form of [enabled: false, audience: "target-audience"].
  • encode_variables: if true, encode the Graphql variables to JSON. Defaults to false.
  • format_response: transforms camelCase keys in response to snake_case. Defaults to false.
  • format_variables: transforms snakecase variable names to camelCase. Defaults tofalse. *http_headers: HTTP headers for the request. Defaults to%{"Content-type": "application/json"}*http_options: HTTP options to be passed to Telepoison. Defaults to[timeout: 1_000, recv_timeout: 16_000]. *log_options: override global configuration for logging errors. Takes the form of[log_query_on_error: false, log_response_on_error: false]*max_attempts: number of times the request will be retried upon failure. Defaults to1. ⚠️ Deprecated: use retry_options instead. *retry_options: override configuration regarding retries, namely *delay: meaning depends ontiming*:constant: retry everdelayms *:exponential: start retrying withdelayms *max_retries. Defaults to0*policy: a function that takes an error as input and returnstrue/falseto indicate whether to retry the error or not. Defaults to "always retry" (fn -> true end). *timing: either:exponentialor:constant, indicates how frequently retries are made (e.g. every 1s, in an exponential manner and so on). Defaults to:exponential` ## Examples elixir defmodule MyBridge do use BridgeEx.Graphql, endpoint: "http://my-api.com/graphql" end defmodule MyBridge do use BridgeEx.Graphql, endpoint: "http://my-api.com/graphql", auth0: [enabled: true, audience: "target-audience"] end