VBT.Graphql.Case (vbt v0.1.0) View Source
ExUnit case template for writing tests which issue GraphQL requests.
Example:
defmodule SomeTest do
use VBT.Graphql.Case,
endpoint: MyEndpoint,
api_path: "/api/graphql",
repo: MyRepo,
async: true
describe "current_user" do
test "returns current user's login" do
{:ok, token} = call(auth_query, variables: %{login: login, password: password})
assert {:ok, data} = call(current_user_query, auth: token)
assert data.login == "expected login"
end
test "returns an error when not authenticated" do
assert {:ok, response} = call(current_user_query, auth: token)
assert "unauthenticated" in errors(response)
end
end
Link to this section Summary
Functions
Makes a GraphQL query call.
Makes a GraphQL call, returning data on success, raising an assertion error otherwise.
Returns error messages from the GraphQL response errors.
Returns error messages for the given field from the GraphQL response errors.
Link to this section Types
Specs
Specs
data() :: %{required(atom()) => data_value()}
Specs
data_value() :: number() | String.t() | data() | [data_value()]
Specs
error() :: %{ :message => String.t(), optional(:path) => [String.t()], optional(:locations) => [ %{column: non_neg_integer(), line: non_neg_integer()} ], optional(:extensions) => [%{field: String.t()}] }
Specs
Specs
Specs
Link to this section Functions
Specs
Makes a GraphQL query call.
Specs
Makes a GraphQL call, returning data on success, raising an assertion error otherwise.
Specs
Returns error messages from the GraphQL response errors.
Specs
Returns error messages for the given field from the GraphQL response errors.