From 094a43a9f67c4f48d1e150daae6170840fa12785 Mon Sep 17 00:00:00 2001 From: James Harton Date: Wed, 24 Apr 2024 11:15:46 +1200 Subject: [PATCH] chore: Add failing test case for string union values parsed as numbers. --- test/create_test.exs | 48 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/test/create_test.exs b/test/create_test.exs index 1c9c5cf..bb0e410 100644 --- a/test/create_test.exs +++ b/test/create_test.exs @@ -146,6 +146,54 @@ defmodule AshGraphql.CreateTest do } = result end + test "an embedded union type uses the correct types" do + assert {:ok, resp} = + """ + mutation SimpleCreatePost($input: SimpleCreatePostInput) { + simpleCreatePost(input: $input) { + result{ + text1 + simpleUnion { + ... on SimpleUnionString { + value + } + ... on SimpleUnionInt { + value + } + } + } + errors{ + message + } + } + } + """ + |> Absinthe.run(AshGraphql.Test.Schema, + variables: %{ + "input" => %{ + "text1" => "foo", + "simpleUnion" => %{ + "string" => "5" + } + } + } + ) + + refute Map.has_key?(resp, :errors) + + assert %{ + data: %{ + "simpleCreatePost" => %{ + "result" => %{ + "simpleUnion" => %{ + "value" => "5" + } + } + } + } + } = resp + end + test "an embedded union type can be written to" do resp = """