Add an optional property parameter to DataLoaders methods. #7081
Labels
🎉 enhancement
New feature or request
🌶️ green donut
🔍 investigate
Indicates that an issue or pull request needs more information.
Product
Green Donut
Is your feature request related to a problem?
I don't think its a problem is more of a inconvenience, if an Entity has relationships with more than one Entity, and i want to able to include those entities in my query i have to build one DataLoader for each relationship (im using EF Core) because there's no way to pass the property that i need to query for in the where clause of ef core.
For example, the models Products, Category and Company. Products has a CategoryId and CompanyId foreign keys, and Company and Category models have List Products navigation properties,
If i query for Company and want to include Products in my query i got a build a GroupedDataLoader that searches for products like:
context.Products.Where(p=> keys.Contains( p.CompanyId ))
If i query for Category and want to include Products in my query i got a build a GroupedDataLoader that searches for products like:
context.Products.Where(p=> keys.Contains( p.CategoryId ))
Right now my Products model has relationships with:
this means i have to make one GroupedDataLoader for each, at least thats how i know how to do it right now, don't know if theres a better way to do it.
The solution you'd like
Passing the property as a parameter in some way is the best solution that comes to my mind. I know that HotChocolate its made to work with multiple database providers but maybe with an optional parameter in the LoadBatchAsync method might work, something like Product.CategoryId.
The text was updated successfully, but these errors were encountered: