-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Improve usability of internal Vendure services #1103
Comments
This is maybe my most major grievance with Vendure, since I make heavy use of the core services in plugins. Instead of the |
@heiko-r thanks for the feedback.
This would have the advantage of doing all joins in a single query, rather than a second query for the Arguments against this approach:
I think it is still worth thinking about a solution like this, but for now I would tend towards a "magicHydrate" type of approach which should be possible to implement in the next minor version with zero breaking changes. |
This was a fun challenge to implement! Arrived at what I think is a nice API to work with - basically as covered above but with th following features:
More details here: vendure/packages/core/src/service/helpers/entity-hydrator/entity-hydrator.service.ts Lines 16 to 38 in 28e6a3a
|
Still to do for next minor: Include Services & Helpers in vendure.io docs. |
It's kind of difficult to write services that operate on products / product variants or other internal entities. (A) You can't use the GraphQL API from within the same process (or it's not recommended). (B) The internal services are not documented and somewhat inconsistent and (C) it's really cumbersome to use TypeORM directly. I will give examples for B and C:
My biggest problem, as I said, is that I can't explicitly tell the services to eagerly fetch everything. One solution would be to implement a kind of "hydration" function that will eagerly load all relations for a given VendureEntity. For example:
The text was updated successfully, but these errors were encountered: