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
t()
View Source
t() :: %Grapher.GraphQL.Request{mutation: mutation_string(), query: query_string(), variables: var_data()}
Link to this section Functions
Link to this function
as_json(request)
View Source
as_json(Grapher.GraphQL.Request.t()) :: 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 } }","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 aString.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"}}
Builds a GraphQL Request struct for a query, this is used for the request payload.
Parameters
query
: The GraphQL Query document as aString.t
vars
: A map of variables for the query
Examples
iex> Request.query("query {}", %{var: "value"})
%Request{mutation: nil, query: "query {}", variables: %{var: "value"}}