wormwood v0.1.0 Wormwood.GQLCase
This module defines a few helpful macros when testing against an Absinthe GraphQL schema. It essentially registers an Absinthe schema and a GQL document to the module they're called in.
Link to this section 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
or set_gql
.
Call this macro in the module you've loaded a document into using load_gql
or set_gql
.
Call this macro in the module where you want to query using a static string as your query.
Link to this section Functions
Call this macro in the module you wish to load your GQL document in.
It takes 2 arguments, the first is your Absinthe schema module, the second is a path to a GQL file that contains a GraphQL query or mutation.
For example:
defmodule MyCoolApplication.MyModule do
load_gql MyCoolApplication.MyAbsintheSchema, "assets/js/queries/MyQuery.gql"
# ...
Call this macro in the module you've loaded a document into using load_gql
or set_gql
.
Calling this will execute the document loaded into the module against the schema loaded in the module.
It accepts a keyword list for options
that are passed into Absinthe.run/3
.
Please see the Absinthe docs for more information on the options that can be passed to this macro.
Returns a tuple of the query result from the Absinthe.run/3
call.
For example:
result = query_gql(variables: %{}, context: %{})
{:ok, query_data} = result
Call this macro in the module you've loaded a document into using load_gql
or set_gql
.
Calling this will execute the document loaded into the module against the schema loaded in the module.
Absinthe will use the phases in the "pipeline_phases" list argument when running.
It also accepts a keyword list for options
that are passed into Absinthe.run/3
.
Please see the Absinthe docs for more information on the options that can be passed to this macro.
Returns a tuple of the query result from the Absinthe.Pipeline.run/2
call.
For example:
pipeline = [Absinthe.Phase.Parse, Absinthe.Phase.Blueprint]
result = query_gql_with_pipeline(pipeline)
assert {:ok, %Absinthe.Blueprint{} = _blueprint, _pipeline} = result
Call this macro in the module where you want to query using a static string as your query.
It takes 2 arguments, the first is your Absinthe schema module, the second is a string of a GQL query or mutation. This still supports imports, they will be resolved from the current working directory. (Most likely the top level of your app)
For example:
defmodule MyCoolApplication.MyModule do
set_gql MyCoolApplication.MyAbsintheSchema, "query { some { cool { gql { id } }}}"
# ...