2023-02-17 17:33:54 +13:00
|
|
|
defmodule Foo do
|
|
|
|
@moduledoc false
|
|
|
|
use Ash.Resource,
|
|
|
|
data_layer: :embedded,
|
|
|
|
extensions: [
|
|
|
|
AshGraphql.Resource
|
|
|
|
]
|
|
|
|
|
|
|
|
graphql do
|
|
|
|
type :foo_embed
|
|
|
|
end
|
|
|
|
|
|
|
|
attributes do
|
|
|
|
attribute :type, :atom do
|
2024-04-02 07:03:06 +13:00
|
|
|
public?(true)
|
2023-02-17 17:33:54 +13:00
|
|
|
constraints(one_of: [:foo])
|
|
|
|
writable?(false)
|
|
|
|
end
|
|
|
|
|
|
|
|
attribute :foo, :string do
|
2024-04-02 07:03:06 +13:00
|
|
|
public?(true)
|
2023-02-17 17:33:54 +13:00
|
|
|
allow_nil? false
|
|
|
|
end
|
|
|
|
end
|
2023-06-09 16:45:39 +12:00
|
|
|
|
|
|
|
calculations do
|
2024-04-02 07:03:06 +13:00
|
|
|
calculate(:always_true, :boolean, expr(true), public?: true)
|
|
|
|
calculate(:always_nil, :boolean, expr(nil), public?: true)
|
2023-06-09 16:45:39 +12:00
|
|
|
end
|
2023-02-17 17:33:54 +13:00
|
|
|
end
|
|
|
|
|
|
|
|
defmodule Bar do
|
|
|
|
@moduledoc false
|
|
|
|
use Ash.Resource,
|
|
|
|
data_layer: :embedded,
|
|
|
|
extensions: [
|
|
|
|
AshGraphql.Resource
|
|
|
|
]
|
|
|
|
|
|
|
|
graphql do
|
|
|
|
type :bar_embed
|
|
|
|
end
|
|
|
|
|
|
|
|
attributes do
|
|
|
|
attribute :type, :atom do
|
2024-04-02 07:03:06 +13:00
|
|
|
public?(true)
|
2023-02-17 17:33:54 +13:00
|
|
|
constraints(one_of: [:foo])
|
|
|
|
writable?(false)
|
|
|
|
end
|
|
|
|
|
|
|
|
attribute :bar, :string do
|
2024-04-02 07:03:06 +13:00
|
|
|
public?(true)
|
2023-02-17 17:33:54 +13:00
|
|
|
allow_nil? false
|
|
|
|
end
|
|
|
|
end
|
2023-06-09 16:45:39 +12:00
|
|
|
|
|
|
|
calculations do
|
2024-04-02 07:03:06 +13:00
|
|
|
calculate(:always_true, :boolean, expr(true), public?: true)
|
|
|
|
calculate(:always_false, :boolean, expr(false), public?: true)
|
2023-06-09 16:45:39 +12:00
|
|
|
end
|
2023-02-17 17:33:54 +13:00
|
|
|
end
|