I am asking this question in terms of the speed/execution time as well as test coverage.
Considering these 2 ways, which one should be ideal to test GraphQL.
Second way does not ask for conn, doesn’t POST. So, can I assume its faster or much faster.
If I have 50 Schema or query and second method saves time, Should i add an additional test to ensure the POST to graphQL is working and getting me back the result.
Last project I worked… it took few minutes for all tests to run. That was bothering me.
I am open to suggestions.
defmodule DakgharWeb.GraphQL.Schema.TopicSchemaTest do
use DakgharWeb.ConnCase
@query """
query{listTopics {
code
name
}}
"""
describe "list all topics" do
test "success - returns blank for no topics with conn", %{conn: conn} do
assert %{
"data" => %{"listTopics" => data}
} =
conn
|> post("/graphql", %{query: @query, variables: %{}})
|> json_response(200)
assert data == []
end
test "success - returns blank for no topics without conn" do
result = Absinthe.run(@query, DakgharWeb.GraphQL.Schema, variables: %{})
assert result = {:ok, data: %{"data" => []}}
end
end
end