ash_graphql/test/resource_test.exs
Riccardo Binetti 9674614b62
feat: allow resources without types (#121)
* fix: regenerate spark formatter and cheatsheet

Make CI pass again

* feat: allow resources without types

Ensure they only expose generic action queries. Add checks to ensure that either
`type :resource_type` or `generate_object? false` is passed if it's needed.

Close #119
2024-03-28 11:16:32 -04:00

26 lines
693 B
Elixir

defmodule AshGraphql.ResourceTest do
use ExUnit.Case
test "object generated according to generate_object?" do
assert %Absinthe.Type.Object{
identifier: :user
} = Absinthe.Schema.lookup_type(AshGraphql.Test.Schema, :user)
assert nil == Absinthe.Schema.lookup_type(AshGraphql.Test.Schema, :no_object)
end
test "resource with no type can execute generic queries" do
resp =
"""
query NoObjectCount {
noObjectCount
}
"""
|> Absinthe.run(AshGraphql.Test.Schema)
assert {:ok, result} = resp
refute Map.has_key?(result, :errors)
assert %{data: %{"noObjectCount" => [1, 2, 3, 4, 5]}} = result
end
end