Request for supporting associations and resolvers
Hi,
This is a request for supporting associations and resolvers. Something like following:
defmodule Person do
use Dlex.Node
@derive {Phoenix.Param, key: :uid}
import Ecto.Changeset
schema "persons" do
field :name, :string
field :age, :integer
field :works_at, :uid, model: Company
field :company_count, :integer, virtual: true, resolve: "count(works_at)"
end
...
Thanks, Gorav
Hi!
Thank you for request! 👍
Are there any analogy functionality to resolve in ecto? I would like to see find something similar in ecto, before continue on this.
There are references from Absinthe: https://hexdocs.pm/absinthe/Absinthe.Resolution.html https://hexdocs.pm/absinthe/query-arguments.html https://hexdocs.pm/absinthe/ecto.html https://www.howtographql.com/graphql-elixir/2-queries/
Could not find anything directly from ecto
Also, how do we handle associations? has_many and belongs_to which ecto supports?
Could we have something like:
defmodule App.Person do
...
has_many :lands, [:uid]
...
end
defmodule App.Land do
...
belongs_to :person, :uid
...
end
AND
defmodule App.Land do
...
belongs_to :owner, :uid, type: App.Person, reverse: true
...
end