How to work with relationships in Absinthe, Ecto and Dataloader?

How to work with relationships in Absinthe, Ecto and Dataloader? Below is the link of the repo. The code does not seem to work. It gives association errors. Thoughts?

Hi @inblack67 can you point to specific code that doesn’t work, or include the error message?

2 Likes

I have been looking for documentation on this subject. For example, how would one go about using dataloader for the following model structure (i.e. has_many through):

  schema "people" do
    field :email, :string
    field :first_name, :string
    field :last_name, :string
    field :username, :string

    has_many :friendships, Friendship
    has_many :friends, through: [:friendships, :friend]

    timestamps()
  end

  schema "friendships" do
    belongs_to :person, Person
    belongs_to :friend, Person

    timestamps()
  end
1 Like

Can your show the corresponding graphql schema? What have you tried so far?

1 Like

@benwilson512 You can find the corresponding GraphQL schema here:

I was able to resolve my issue after reading the finer points within the Absinthe GraphQL documentation. My issue was that I wasn’t defining the context function within schema.ex file.

1 Like