Cognac (Cognac v0.8.0) View Source

Link to this section Summary

Functions

Convert keyword list/tuple list to GraphQL mutation query string

Marks type as non-null, appending with an exclamation mark (!).

Convert keyword list/tuple list to GraphQL query string

Convert keyword list/tuple list to GraphQL subscription query string

Marks value as variable, helping with correct annotation using ($) and all that jazz.

Link to this section Functions

Link to this function

mutation(query, options \\ [])

View Source

Convert keyword list/tuple list to GraphQL mutation query string

iex> mutation = [hero: [:name, friends: [:name]]]
iex> Cognac.mutation(mutation) |> IO.puts
mutation{updateHero(name:"Steve"){name}}

Options

  • :output
    • :iodata (default) - Outputs as IO data
    • :binary - Outputs query as a binary string
  • pretty
    • false (default) - Outputs minimal query
    • true - Outputs prettified query with indentation and linebreaks
Link to this function

mutation_operation(name, arguments, query, options \\ [])

View Source

Specs

mutation_operation(binary(), list() | keyword(), list() | keyword(), keyword()) ::
  binary() | iodata()
Link to this macro

non_null(type)

View Source (macro)

Marks type as non-null, appending with an exclamation mark (!).

Link to this function

query(query, options \\ [])

View Source

Convert keyword list/tuple list to GraphQL query string

iex> query = [hero: [:name, friends: [:name]]]
iex> Cognac.query(query) |> IO.puts
# query{hero{name friends{name}}}

Options

  • :output
    • :iodata (default) - Outputs as IO data
    • :binary - Outputs query as a binary string
  • pretty
    • false (default) - Outputs minimal query
    • true - Outputs prettified query with indentation and linebreaks
Link to this function

query_operation(name, arguments, query, options \\ [])

View Source

Specs

query_operation(binary(), list() | keyword(), list() | keyword(), keyword()) ::
  binary() | iodata()
Link to this function

subscription(query, options \\ [])

View Source

Convert keyword list/tuple list to GraphQL subscription query string

iex> subscription = [heroUpdated: [:name]]
iex> Cognac.subscription(subscription) |> IO.puts
subscription{heroUpdated{name}}

Options

  • :output
    • :iodata (default) - Outputs as IO data
    • :binary - Outputs query as a binary string
  • pretty
    • false (default) - Outputs minimal query
    • true - Outputs prettified query with indentation and linebreaks
Link to this function

subscription_operation(name, arguments, query, options \\ [])

View Source

Specs

subscription_operation(
  binary(),
  list() | keyword(),
  list() | keyword(),
  keyword()
) ::
  binary() | iodata()
Link to this macro

variable(name)

View Source (macro)

Marks value as variable, helping with correct annotation using ($) and all that jazz.