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
t()
View Source
t() :: %Grapher.GraphQL.Response{data: data(), errors: errors(), status_code: status_code(), transport_error: transport_error()}
Link to this section Functions
Link to this function
build(map)
View Source
build(HTTPoison.Response.t()) :: Grapher.GraphQL.Response.t()
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}