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

ProductProvider needs to warn about missing variants #736

Open
frehner opened this issue Mar 29, 2023 · 1 comment
Open

ProductProvider needs to warn about missing variants #736

frehner opened this issue Mar 29, 2023 · 1 comment

Comments

@frehner
Copy link
Contributor

frehner commented Mar 29, 2023

What is the location of your example repository?

No response

Which package or tool is having this issue?

hydrogen-react

What version of that package or tool are you using?

2023.1.7

What version of Remix are you using?

n/a

Steps to Reproduce

We need to have a better error/warning for this situation:

  1. Use ProductProvider, passing a data prop that doesn't contain variants
  2. Get a warning from flattenConnection that it couldn't flatten the connection

const variants = useMemo(
() => flattenConnection(product.variants ?? {}),
[product.variants],
);

Expected Behavior

ProductProvider should have a warning with details of what's missing on the product prop.

Actual Behavior

flattenConnection(): The connection did not contain either "nodes" or "edges.node". Returning an empty array.
@frehner
Copy link
Contributor Author

frehner commented Mar 29, 2023

Also need to do this for sellingPlanGroups and sellingPlanAllocations

In other words, any place that flattenConnection is used there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant