View Source GraphQLDocument.Value (GraphQLDocument v0.2.2)

A Value can be any of the following Elixir types:

Values are sent inside Arguments (see GraphQLDocument.Argument) or as default values in Variable Definitions (see GraphQLDocument.Variable.definition/0).

Link to this section Summary

Functions

Returns a Value as iodata to be inserted into a Document.

Link to this section Types

@type t() ::
  integer()
  | float()
  | String.t()
  | boolean()
  | nil
  | atom()
  | [t()]
  | %{optional(atom()) => t()}
  | GraphQLDocument.Variable.t()

Link to this section Functions

@spec render(t()) :: iodata()

Returns a Value as iodata to be inserted into a Document.

Returns native Elixir date and datetime structures as strings in ISO8601 format.

examples

Examples

iex> render(~D[2019-11-12])
"\"2019-11-12\""

iex> render(~N[2019-11-12T10:30:25])
"\"2019-11-12T10:30:25\""

iex> render(DateTime.from_naive!(~N[2019-11-12T10:30:25], "Etc/UTC"))
"\"2019-11-12T10:30:25Z\""

iex> render(Jedi)
"Jedi"

iex> render(nil)
"null"

iex> render({:var, :allegiance})
[?$, "allegiance"]

iex> render([])
"[]"

iex> render("sOmE-sTrInG")
"\"sOmE-sTrInG\""

iex> render(true)
"true"

iex> render(false)
"false"

iex> render(%{map: %{with: [nested: ["data"]]}})
[?{, [["map", ?:, 32, [?{, [["with", ?:, 32, [?{, [["nested", ?:, 32, [?[, ["\"data\""], ?]]]], ?}]]], ?}]]], ?}]

iex> render(%{map: %{with: [nested: ["data"]]}}) |> IO.iodata_to_binary()
"{map: {with: {nested: [\"data\"]}}}"