absinthe-graphql / absinthe_ecto

DEPRECATED: Use dataloader
MIT License
130 stars 36 forks source link

New query fun addition breaks :through associations #18

Closed dmarkow closed 7 years ago

dmarkow commented 7 years ago

The recent merge of #11 (committed in 29e99216c4080470455d94ed6888b6930ecc3abd) breaks :through associations.

defmodule Api.Deliverable do
  # ...
  belongs_to :plan, Api.Plan
  has_one :project, through: [:plan, :project]
  # ...

Now when I try to use this in a query:

object :deliverable do
  field :project, :project, resolve: assoc(:project)
end

I get:

** (MatchError) no match of right hand side value: %Ecto.Association.HasThrough{cardinality: :one, field: :project, on_cast: nil, owner: Api.Deliverable, owner_key: :plan_id, relationship: :child, through: [:plan, :project], unique: true}

This is because the %Ecto.Association.HasThrough{} struct doesn't include the queryable key (which the new updates try to match on).

Didn't realize 0.1.0 was pushed to Hex last month so switching to that instead of master is working fine for now. I'll try and get a PR in when I have some time.

benwilson512 commented 7 years ago

Hey great catch thanks, I'll get a fix in.