View Source GraphQLDocument.Operation (GraphQLDocument v0.2.2)
An Operation is a query, mutation, or subscription.
Link to this section Summary
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.
variables
: SeeGraphQLDocument.Variable.definition/0
fragments
: SeeGraphQLDocument.Fragment.definition/0
directives
: SeeGraphQLDocument.Directive.t/0
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
@spec render(operation_type(), [GraphQLDocument.Selection.t()], [option()]) :: String.t()
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
}
}
}\
"""