Grapher v0.7.0 Grapher.GraphQL.Request View Source

The Grapher Request struct is a collection of all document strings along with any variables.

Link to this section Summary

Functions

Converts a Grapher.GraphQL.Request.t struct to JSON format

Builds a GraphQL Request struct for a query, this is used for the request payload

Link to this section Types

Link to this type query_string() View Source
query_string() :: String.t()
Link to this type t() View Source
t() :: %Grapher.GraphQL.Request{query: query_string(), variables: var_data()}
Link to this type var_data() View Source
var_data() :: nil | map()

Link to this section Functions

Link to this function as_json(request) View Source
as_json(%{query: String.t(), variables: var_data()}) :: String.t()

Converts a Grapher.GraphQL.Request.t struct to JSON format.

Parameters

  • request: The request struct to be converted

Examples

iex> request = %Request{query: "query { stores{ items } }", variables: nil}
iex> Request.as_json(request)
"{"variables":null,"query":"query { stores{ items } }"}"
Link to this function new(document, vars \\ nil) View Source
new(String.t(), nil | map()) :: map()

Builds a GraphQL Request struct for a query, this is used for the request payload.

Parameters

  • document: The GraphQL Query document as a String.t
  • vars: A map of variables for the query

Examples

iex> Request.new("query {}", %{var: "value"})
%Request{query: "query {}", variables: %{var: "value"}}