View Source GraphQLDocument.Argument (GraphQLDocument v0.2.2)

Arguments are specified in a keyword list.

[width: 100, height: 50]

See render/1 for examples of more complicated argument sets.

Link to this section Summary

Types

t()

A GraphQL argument.

Functions

Returns a list of Arguments as iodata to be inserted into a Document.

Link to this section Types

Link to this section Functions

@spec render([t()]) :: iolist()

Returns a list of Arguments as iodata to be inserted into a Document.

Any valid GraphQL Value can be sent as the value of an Argument. (See GraphQLDocument.Value.t/0.)

examples

Examples

iex> render(height: 100, width: 50)
...> |> IO.iodata_to_binary()
"(height: 100, width: 50)"

iex> render(name: nil, age: 50)
...> |> IO.iodata_to_binary()
"(name: null, age: 50)"

iex> render(name: "Joshua", city: "Montreal", friendsOfFriends: true)
...> |> IO.iodata_to_binary()
"(name: \"Joshua\", city: \"Montreal\", friendsOfFriends: true)"

iex> render(%{person: [
...>   coordinates: [
...>     lat: 123.45,
...>     lng: 678.90
...>   ]
...> ]})
...> |> IO.iodata_to_binary()
"(person: {coordinates: {lat: 123.45, lng: 678.9}})"

iex> render(coordinates: [
...>   lat: {:var, :myLat},
...>   lng: {:var, :myLng}
...> ])
...> |> IO.iodata_to_binary()
"(coordinates: {lat: $myLat, lng: $myLng})"

iex> render(ids: [1, 2, 3])
...> |> IO.iodata_to_binary()
"(ids: [1, 2, 3])"