-
Notifications
You must be signed in to change notification settings - Fork 142
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Many-To-Many Relationship Query Problem #22
Comments
Yes, I found this over the weekend and started working on a fix. Typeorm doesnt make querying relationships with filters easy. I hope to get this fixed by the end of the week, |
ok, good that you also found respective issue. |
This will be part of v0.3.0 which also includes dataloader support, so you wont see 10 separate queries. but 2 one to get the |
That is awesome |
just wanted to give feedback to this issue. |
Dear @doug-martin ,
and once again I write to you to describe an issue i have found ;) Sorry for bothering you again ;)
The issue i stumbled upon is with
Many to Many
relationships between entities.Consider the following example:
I have two entities
Organization
andDoctor
. Thereby, one organization has many doctors and one doctor can be a member in various organizations.My models look like this (simplified):
Then i set up my
OrganizationResolver
like this:Note that
assigning a doctor (member) to an organization
works like a charm, via the auto-generated endpoint fromrelations.many.members.disableUpdate: false
.However, i am NOT able to properly query (!) the members of an organization. Consider this query:
results in this response:
See that all organizations are connected to the same doctor? well - that is certainly not true from the DB point-of-view. The
organization_members
table (join-table) certainly has only one relation between one doctor and one organization.When i logged the queries sent to the database, i got this result:
Basically - it first fetches a paginated set of
Organization
s from the database (this is correct).However, then it fetches n times from the
doctors
table - without going through the join-table relationship.Furthermore, this query does only work "from this side". When querying from the other side (like this), this results in an error:
throws this error:
and of course it does not exist, because respective column should be located within the
organization_members
table.Am i doing something wrong? I guess, the
many-to-many
relations are not (yet) supported? Am i correct on this one?All the best and thank you very much for your time and effort!
Johannes
The text was updated successfully, but these errors were encountered: