Grapher v0.7.1 Grapher.GraphQL.Response View Source

Conveniences for structuring the response form the server.

Link to this section Summary

Functions

Creates a Grapher.GraphQL.Response.t struct from an HTTPoison.Response.t struct

Link to this section Types

Link to this type data() View Source
data() :: :empty | map()
Link to this type errors() View Source
errors() :: :empty | map()
Link to this type status_code() View Source
status_code() :: :empty | integer()
Link to this type t() View Source
t() :: %Grapher.GraphQL.Response{data: data(), errors: errors(), status_code: status_code(), transport_error: transport_error()}
Link to this type transport_error() View Source
transport_error() :: :empty | String.t()

Link to this section Functions

Creates a Grapher.GraphQL.Response.t struct from an HTTPoison.Response.t struct.

Parameters

  • response: An HTTPoison response

Examples

iex> Response.build(mixed_response())
%Response{data: %{store: %{id: 3383, owner: "Bob"}}, errors: %{email_address: "Missing"}, status_code: 200}

iex> Response.build(error_response())
%Response{data: :empty, errors: %{email_address: "Missing"}, status_code: 200}

iex> Response.build(success_response())
%Response{data: %{store: %{id: 3383, owner: "Bob"}}, errors: :empty, status_code: 200}

iex> Response.build(transport_error())
%Response{transport_error: "Not Authorized", status_code: 400}