GqlCase (GqlCase v0.6.0)

View Source

This module defines helper macros to work with Graphql and Guardian

Summary

Functions

Call this macro in the module you wish to load your GQL document from a file.

Call this macro in the module you wish to load your GQL document from a query string.

Call this macro in the module you've loaded a document into using load_gql_file or load_gql_string.

Functions

add_headers(conn, headers)

add_headers(conn, jwt_bearer_fn, opts \\ [])

load_gql_file(file_path)

(macro)

Call this macro in the module you wish to load your GQL document from a file.

It takes one argument, the path to a GQL file that contains a GraphQL query or mutation.

For example:

defmodule MyApp do
  load_gql_file "assets/js/queries/MyQuery.gql"
  # ...
end

load_gql_string(query_string)

(macro)

Call this macro in the module you wish to load your GQL document from a query string.

It takes one argument, a string containing a GraphQL query or mutation.

For example:

defmodule MyApp do
  load_gql_string """
  query {
    hello
  }
  """
  # ...
end

merge_headers_with_priority(header_lists)

query_gql(opts \\ [])

(macro)

Call this macro in the module you've loaded a document into using load_gql_file or load_gql_string.

Calling this will execute the document loaded into the module against gql path loaded in the module. It accepts a keyword list for options. These options might be variables and current_user.

Returns the query result from the HTTP GQL call.

For example:

result = query_gql(variables: %{}, current_user: %{})
%{"data" => %{} = result