Skip to content
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

AssetInterceptor not running for property resolvers #146

Closed
michaelbromley opened this issue Aug 26, 2019 · 1 comment
Closed

AssetInterceptor not running for property resolvers #146

michaelbromley opened this issue Aug 26, 2019 · 1 comment
Assignees
Labels
type: bug 🐛 Something isn't working @vendure/core

Comments

@michaelbromley
Copy link
Member

Describe the bug
When an entity has an entity resolver field defined, and that field includes Assets, those Assets are not passing through the AssetInterceptor and therefore the preview and source URLs are not being correctly resolved.

To Reproduce

  1. Add an asset to a ProductVariant in the product detail page
  2. Save changes
  3. Refresh page
  4. ProductVariant image is a broken link. Does not include the prefix.

Expected behavior
ProductVariant asset urls should be correctly prefixed.

Environment (please complete the following information):

  • @vendure/core version: 0.1.2-beta.12

Additional context
Debugging with breakpoints shows that the sequence is as follows:

  1. ProductService.product resolver invoked, returns a Product (without variants)
  2. AssetInterceptor.intercept method called on the object returned in 1. And assets present are correctly prefixed.
  3. ProductEntityResolver.variants method is called.
  4. Response is returned without the variant assets running through the interceptor.
@michaelbromley michaelbromley added type: bug 🐛 Something isn't working @vendure/core labels Aug 26, 2019
@michaelbromley michaelbromley self-assigned this Aug 26, 2019
@michaelbromley
Copy link
Member Author

michaelbromley commented Aug 26, 2019

This is a limitation of Nest - see nestjs/graphql#320. The probable solution to this is to convert the AssetInterceptor into an Apollo server plugin, which should get run on the final object just prior to returning the response to the client. This would also potentially improve performance since only the selected subset of fields may be needed to be traversed.

@michaelbromley michaelbromley changed the title AssetInterceptor not running for sub-resolvers AssetInterceptor not running for property resolvers Aug 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug 🐛 Something isn't working @vendure/core
Projects
None yet
Development

No branches or pull requests

1 participant