Grapher v0.6.0 Grapher.GraphQL.Request View Source

The Grapher Request struct is a collection of all query and mutation documents 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 mutation, this is used for the request payload

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

Link to this section Types

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

Link to this section Functions

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 } }","mutation":null}"
Link to this function mutation(mutation, vars \\ nil) View Source
mutation(String.t(), nil | map()) :: map()

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

Parameters

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

Examples

iex> Request.mutation("mutation { thing(name: $name) { id } }", %{name: "bob"})
%Request{query: nil, mutation: "mutation { thing(name: $name) { id } }", variables: %{name: "bob"}}
Link to this function query(query, vars \\ nil) View Source
query(String.t(), nil | map()) :: map()

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

Parameters

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

Examples

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