mirror of
https://framagit.org/framasoft/mobilizon.git
synced 2024-12-26 17:59:26 +00:00
8094f1d80a
Close #247 Signed-off-by: Thomas Citharel <tcit@tcit.fr>
39 lines
755 B
Elixir
39 lines
755 B
Elixir
defmodule MobilizonWeb.AbsintheHelpers do
|
|
use Phoenix.ConnTest
|
|
@endpoint MobilizonWeb.Endpoint
|
|
|
|
@moduledoc """
|
|
Absinthe helpers for tests
|
|
"""
|
|
def query_skeleton(query, query_name) do
|
|
%{
|
|
"operationName" => "#{query_name}",
|
|
"query" => "query #{query_name} #{query}",
|
|
"variables" => "{}"
|
|
}
|
|
end
|
|
|
|
def mutation_skeleton(query) do
|
|
%{
|
|
"operationName" => "",
|
|
"query" => "#{query}",
|
|
"variables" => ""
|
|
}
|
|
end
|
|
|
|
def graphql_query(conn, options) do
|
|
conn
|
|
|> post(
|
|
"/api",
|
|
build_query(options[:query], options[:variables])
|
|
)
|
|
|> json_response(200)
|
|
end
|
|
|
|
defp build_query(query, variables) do
|
|
%{
|
|
"query" => query,
|
|
"variables" => variables
|
|
}
|
|
end
|
|
end
|