GqlCase (GqlCase v0.1.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 in.

Call this macro in the module you've loaded a document into using load_gql.

Functions

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

load_gql(file_path)

(macro)

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

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

For example:

defmodule MyApp do
  load_gql MyApp.MyAbsintheSchema, "assets/js/queries/MyQuery.gql"
  # ...
end

query_gql(opts \\ [])

(macro)

Call this macro in the module you've loaded a document into using load_gql.

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