View Source GraphQLDocument.Selection (GraphQLDocument v0.2.0)
A Selection is the list of Fields or Fragments to be returned in an object.
Link to this section Summary
Functions
Returns the list of selections in a SelectionSet as iodata to be inserted into a Document.
Link to this section Types
@type t() :: GraphQLDocument.Field.t() | GraphQLDocument.Fragment.spread() | GraphQLDocument.Fragment.inline()
Link to this section Functions
Returns the list of selections in a SelectionSet as iodata to be inserted into a Document.
examples
Examples
iex> render([lightsaber: [:color, :style]], 1) |> IO.iodata_to_binary()
"""
{
lightsaber {
color
style
}
}\
"""
iex> render(
...> [
...> invoices: {
...> [customer: "123456"],
...> [
...> :id,
...> :total,
...> items: ~w(description amount),
...> payments: {[after: "2021-01-01", posted: true], ~w(amount date)}
...> ]
...> }
...> ],
...> 1
...> )
...> |> IO.iodata_to_binary()
"""
{
invoices(customer: \"123456\") {
id
total
items {
description
amount
}
payments(after: \"2021-01-01\", posted: true) {
amount
date
}
}
}\
"""
iex> render([foo: :bar], 1)
** (ArgumentError) Expected a field; received {:foo, :bar}
iex> render([foo: [:bar]], 0)
** (ArgumentError) indent_level must be at least 1; received 0