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 cart.get() returning empty object for invalid ids #2258

Merged
merged 3 commits into from
Jun 19, 2024
Merged

Conversation

frandiox
Copy link
Contributor

Closes #2242

@wizardlyhel would this be the right fix? If we change formatAPIResult it would affect many other methods in the cart, and I think cart.get is the only nullable one, right?

@frandiox frandiox requested a review from a team June 18, 2024 03:25
Copy link
Contributor

shopify bot commented Jun 18, 2024

Oxygen deployed a preview of your fd-fix-null-cart branch. Details:

Storefront Status Preview link Deployment details Last update (UTC)
metaobjects ✅ Successful (Logs) Preview deployment Inspect deployment June 18, 2024 3:37 AM
third-party-queries-caching ✅ Successful (Logs) Preview deployment Inspect deployment June 18, 2024 3:37 AM
custom-cart-method ✅ Successful (Logs) Preview deployment Inspect deployment June 18, 2024 3:37 AM
classic-remix ✅ Successful (Logs) Preview deployment Inspect deployment June 18, 2024 3:37 AM
optimistic-cart-ui ✅ Successful (Logs) Preview deployment Inspect deployment June 18, 2024 3:37 AM
Skeleton (skeleton.hydrogen.shop) ✅ Successful (Logs) Preview deployment Inspect deployment June 18, 2024 3:37 AM

Learn more about Hydrogen's GitHub integration.

cartId,
...cartInput,
},
storefront.query<{cart: Cart | null}>(CART_QUERY(cartFragment), {
Copy link
Contributor

Choose a reason for hiding this comment

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

This doesn't need to specify the errors: StorefrontApiErrors type?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That type is added internally in storefront.query as a union to whatever you pass here, so we don't need to specify it manually.

Copy link
Contributor

@wizardlyhel wizardlyhel left a comment

Choose a reason for hiding this comment

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

Aside from that type question, this looks good

@frandiox frandiox merged commit de3f70b into main Jun 19, 2024
13 checks passed
@frandiox frandiox deleted the fd-fix-null-cart branch June 19, 2024 02:35
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.

cart.get returns empty object when cart ID is invalid
2 participants