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

fix(5313-dataloaders-not-found): use SimpleInventory collection to fe… #5314

Merged

Conversation

alex-haproff
Copy link
Contributor

@alex-haproff alex-haproff commented Jul 12, 2019

Resolves #5313
Impact: major
Type: bugfix

Issue

DataLoaders do not exist when Reaction is running in a topic consumer mode or any other "non-web-request-serving" mode. DataLoaders are only supposed to be used in the context of a web request.

Solution

Check if context.dataLoaders is not empty, otherwise fallback to Mongo collection.

Breaking changes

None

…tch inventory docs when the call is made internally, i.e. in the consumer

Signed-off-by: Alex Haproff <[email protected]>
Copy link
Contributor

@focusaurus focusaurus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the quick fix!

@willopez
Copy link
Member

@alex-haproff I see the error reported on #5313 when publishing the example product in the Operator UI.

Steps to reproduce:

  1. Start app with fresh db, on this PR's branch
  2. Attempt to publish example product
  3. Inspect console, to find this error:
Exception while invoking method 'catalog/publish/products' TypeError: Cannot read property 'SimpleInventoryByProductVariantId' of undefined
reaction_1  |     at Promise.asyncApply (imports/plugins/included/simple-inventory/server/no-meteor/utils/inventoryForProductConfigurations.js:31:27)
.
.
.

Copy link
Member

@willopez willopez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comment.

@alex-haproff
Copy link
Contributor Author

hi @willopez thanks for reporting!
At this point I think I will just have to check if DataLoaders are registered and fall back to Mongo collection if needed. It looks like there are few places in Reaction where context is initialised in a different way to the web one.

Copy link
Member

@willopez willopez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@willopez willopez merged commit 82fabec into reactioncommerce:develop Jul 15, 2019
@kieckhafer kieckhafer mentioned this pull request Aug 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants