BridgeEx.Graphql.Utils (bridge_ex v0.3.0-rc.1) View Source

Misc utils for handling Graphql requests/responses.

Link to this section Summary

Link to this section Types

Specs

client_response() :: {:ok, any()} | {:error, any()}

Specs

graphql_response() ::
  {:error, String.t()}
  | {:ok, %{data: term()}}
  | {:ok,
     %{
       error: [
         %{
           message: String.t(),
           locations: [%{line: integer(), column: integer()}]
         }
       ],
       data: term()
     }}

Link to this section Functions

Link to this function

decode_http_response(arg, query)

View Source

Specs

decode_http_response(
  {:ok, HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()}
  | {:error, HTTPoison.Error.t()},
  String.t()
) :: client_response()
Link to this function

normalize_inner_fields(binary)

View Source

Specs

normalize_inner_fields(%{required(atom()) => any()} | String.t()) ::
  %{required(atom()) => any()} | String.t()

Specs

parse_response(graphql_response()) :: client_response()

Specs

retry(
  {:ok, String.t()} | {:error, Jason.EncodeError.t() | Exception.t()},
  (any() -> {:error, String.t()} | {:ok, any()}),
  integer()
) :: client_response()