-
Notifications
You must be signed in to change notification settings - Fork 6
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
Make it possible to set dataKey to a Promise #93
Labels
Comments
That is not a quick fix and at least I will not have cycles in very near future. |
I managed to work around it by wrapping my Product entity and declaring the lazy loaded fields as separate fields. Something like this: class View {
product: Product;
regularPrice: Price;
currentPrice: Price;
// ... Omitted getters and setters
} Instead of passing Product[] as payload I transform it to the View class by just setting the Product as is and assign the lazy loaded fields after calling await on them. let view: View = new View();
view.product = product;
view.regularPrice = await product.regularPrice; // Omitted null check
view.currentPrice = await product.currentPrice; // Omitted null check |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm currently working on a project which uses TypeORM and jsonapter to retrieve and expose a product feed. The product entity is very large and therefore some relations are set to lazy. This wraps the field into a Promise.
Unfortunately when I use the lazy loaded field in a template I can't seem to get it working. The output is omitted and when I log the value it's still resolving the Promise.
Is it possible to implement Promise compatibility here? Or what workaround can I use to be able to pass resolved fields to jsonapter engine?
Template snippet where regularPrice is a lazy loaded field.
content: { ... regularPrice: { dataKey: 'regularPrice', template: priceTemplate }, ... }
The priceTemplate contains another content block with more fields.
The text was updated successfully, but these errors were encountered: