defmodule AshGraphql.CreateTest do use ExUnit.Case, async: false setup do on_exit(fn -> nil # ETS.Set.delete(ETS.Set.wrap_existing!(AshGraphql.Test.Post)) end) end test "a create with arguments works" do resp = """ mutation CreatePost($input: CreatePostInput) { createPost(input: $input) { result{ text } errors{ message } } } """ |> Absinthe.run(AshGraphql.Test.Schema, variables: %{ "input" => %{ "text" => "foobar", "confirmation" => "foobar" } } ) assert {:ok, result} = resp refute Map.has_key?(result, :errors) assert %{data: %{"createPost" => %{"result" => %{"text" => "foobar"}}}} = result end test "arguments are threaded properly" do resp = """ mutation CreatePost($input: CreatePostInput) { createPost(input: $input) { result{ text } errors{ message } } } """ |> Absinthe.run(AshGraphql.Test.Schema, variables: %{ "input" => %{ "text" => "foobar", "confirmation" => "foobar2" } } ) assert {:ok, result} = resp assert %{data: %{"createPost" => %{"result" => nil, "errors" => [%{"message" => message}]}}} = result assert message =~ "Value did not match confirmation" end end