Grapher v0.9.1 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(map) 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.as_json(no_vars())
"{\"variables\":null,\"query\":\"query { stores { items } }\"}"

iex> Request.as_json(snake_atoms())
"{\"variables\":{\"userId\":\"bob\"},\"query\":\"query { stores { items } }\"}"

iex> Request.as_json(camel_atoms())
"{\"variables\":{\"userId\":\"bob\"},\"query\":\"query { stores { items } }\"}"

iex> Request.as_json(string_keys())
"{\"variables\":{\"userId\":\"bob\"},\"query\":\"query { stores { items } }\"}"

iex> Request.as_json(camel_strings())
"{\"variables\":{\"userId\":\"bob\"},\"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"}}