View Source GraphQLDocument.Operation (GraphQLDocument v0.2.2)

An Operation is a query, mutation, or subscription.

Link to this section Summary

Types

Options that can be passed along with the operation.

Functions

Generates GraphQL syntax from a nested Elixir keyword list.

Link to this section Types

@type operation_type() :: :query | :mutation | :subscription
@type option() ::
  {:variables, [GraphQLDocument.Variable.definition()]}
  | {:fragments, [GraphQLDocument.Fragment.definition()]}
  | {:directives, [GraphQLDocument.Directive.t()]}

Options that can be passed along with the operation.

example

Example

GraphQLDocument.query(
  [...],
  variables: [
    postId: {Int, null: false},
    commentType: String
  ],
  fragments: [
    friendFields: {
      on(User),
      [
        :id,
        :name,
        profilePic: field(args: [size: 50])
      ]
    }
  ],
  directives: [
    :debug
    [log: [level: "warn"]]
  ]
)

Link to this section Functions

Link to this function

render(operation_type \\ :query, selections, opts \\ [])

View Source

Generates GraphQL syntax from a nested Elixir keyword list.

example

Example

iex> render(:query,
...>   user: {[id: 3], [
...>     :name,
...>     :age,
...>     :height, documents: [:filename, :url]]})
...>     documents: [
...>       :filename, :url]]})
...>       :url]]})
...>     ]]})
...>   ]}
...> )
"""
query {
  user(id: 3) {
    name
    age
    height
    documents {
      filename
      url
    }
  }
}\
"""