-
-
Notifications
You must be signed in to change notification settings - Fork 439
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
Eager-load multiple relationships through @with
#1132
Comments
As of very recently,repeatable directives are now allowed in principle. We will have to add support for that: #1133 I think allowing multiple |
Repeatable use of the directive is not generally the issue here, it should work in principle - and is now also supported by As of now, the way the batch loader instantiation works does enforce that there is always a single batch loader per field. Since the relation to load is passed during the initial construction, subsequent uses of I am working on moving the relation passing out of the constructor, so the relations to load can added to by multiple directives. |
Hi. I'm using lighthouse 5.0. I have the following type
CorrespondenceItemTargetObject is a Union between 2 types. On the CorrespondenceItemType@targetObjects field resolver I see that only the last relation "targetContracts" is actually loaded. @spawnia I think it is because of the problem you describe on your last comment. |
@with
@with
Hey, I'm trying to kill some N+1 issues and was wondering is this still in the works? I'm specifically trying to eager load multiple relationships and also eager load nested relationships using dot syntax type User {
recommended: Boolean @with(relation: "a") @with(relation: "a.b") @with(relation: "a.b.c")
} |
I tried reenabling the failing test case for this in #2525 and implemented a fix for it. However, this causes other tests to fail. The fundamental issue with this is that relations loaded using |
Thanks, I'll take a look when I find some time. |
Is your feature proposal related to a problem? Please describe.
It seems that it is currently not possible to eager-load multiple relationships through the
@with
directive.Describe the solution you'd like
I think it should either be possible to use the
@with
directive more than once on a single field, or the@with
directive should accept an array of relationships.@with
directive multiple times: I'm not sure if it's currently possible to use any directive more than once on a single field. Is this being prevented for some reason?@with
directive: The question is how to handle scopes then, should they be part of therelations
array (e.grelations: ["relation" => ["scopeOne", "scopeTwo"]]
?Describe alternatives you've considered
I haven't found any alternative to overcome this issue.
The text was updated successfully, but these errors were encountered: