test: add engine deadlock test (#78)

This commit is contained in:
Barnabas Jovanovics 2023-06-16 16:51:50 +02:00 committed by GitHub
parent 1f6e87ff01
commit 7f504bbf17
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 28 additions and 5 deletions

View file

@ -938,6 +938,7 @@ defmodule AshGraphql.ReadTest do
} = result
end
@tag :wip
test "loading relationships through an unnested union with aliases works" do
user =
AshGraphql.Test.User
@ -947,16 +948,26 @@ defmodule AshGraphql.ReadTest do
post =
AshGraphql.Test.Post
|> Ash.Changeset.for_create(
:with_comments,
:create,
%{
author_id: user.id,
text: "a",
comments: [%{text: "comment", author_id: user.id}],
sponsored_comments: [%{text: "sponsored"}],
published: true
}
)
|> AshGraphql.Test.Api.create!()
post =
post
|> Ash.Changeset.for_update(
:update_with_comments,
%{
comments: [%{text: "comment", author_id: user.id}],
sponsored_comments: [%{text: "sponsored"}]
}
)
|> AshGraphql.Test.Api.update!()
resp =
"""
query postLibrary {
@ -972,8 +983,14 @@ defmodule AshGraphql.ReadTest do
...on SponsoredComment {
__typename
text
post {
p: post {
id
user: author {
name
posts {
id
}
}
}
}
}
@ -1012,7 +1029,7 @@ defmodule AshGraphql.ReadTest do
%{
"__typename" => "SponsoredComment",
"text" => "sponsored",
"post" => %{"id" => ^post_id}
"p" => %{"id" => ^post_id, "user" => %{"name" => "fred"}}
},
%{
"__typename" => "Comment",

View file

@ -252,8 +252,10 @@ defmodule AshGraphql.Test.Post do
update :update_with_comments do
argument(:comments, {:array, :map})
argument(:sponsored_comments, {:array, :map})
change(manage_relationship(:comments, type: :direct_control))
change(manage_relationship(:sponsored_comments, type: :direct_control))
end
update :update_confirm do

View file

@ -53,6 +53,10 @@ defmodule AshGraphql.Test.User do
attribute(:name, :string)
end
relationships do
has_many(:posts, AshGraphql.Test.Post, destination_attribute: :author_id)
end
calculations do
calculate(:name_twice, :string, expr(name <> " " <> name))
end