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 the OptimisticCart type to properly retain the generic of line items #2327

Merged
merged 4 commits into from
Jul 31, 2024

Conversation

blittle
Copy link
Contributor

@blittle blittle commented Jul 12, 2024

WHY are these changes introduced?

@brookslybrand reported an issue where the the generic on OptimisticCart did not propagate to line items. For example, this would produce a type of the default cart lines, not the generic api fragment provided.

type CartLine = OptimisticCart<CartApiQueryFragment>['lines']['nodes'];

With this change, now the CartAPIQueryFragment is preserved.

Checklist

  • I've read the Contributing Guidelines
  • I've considered possible cross-platform impacts (Mac, Linux, Windows)
  • I've added a changeset if this PR contains user-facing or noteworthy changes
  • I've added tests to cover my changes
  • I've added or updated the documentation

Copy link
Contributor

shopify bot commented Jul 12, 2024

Oxygen deployed a preview of your bl-fix-optimistic-cart-types-2 branch. Details:

Storefront Status Preview link Deployment details Last update (UTC)
metaobjects ✅ Successful (Logs) Preview deployment Inspect deployment July 29, 2024 6:49 PM
Skeleton (skeleton.hydrogen.shop) ✅ Successful (Logs) Preview deployment Inspect deployment July 29, 2024 6:49 PM
optimistic-cart-ui ✅ Successful (Logs) Preview deployment Inspect deployment July 29, 2024 6:49 PM
custom-cart-method ✅ Successful (Logs) Preview deployment Inspect deployment July 29, 2024 6:49 PM
classic-remix ✅ Successful (Logs) Preview deployment Inspect deployment July 29, 2024 6:49 PM
third-party-queries-caching ✅ Successful (Logs) Preview deployment Inspect deployment July 29, 2024 6:50 PM

Learn more about Hydrogen's GitHub integration.

Comment on lines -68 to +70
lines: OptimisticCartLine[];
lines: CartLine[];
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Needed to change, because just using the OptimisticCartLine directly without a generic means the default API query is used.

Comment on lines +25 to +32
#/***********************************************/
#/********** EXAMPLE UPDATE STARTS ************/
sellingPlanAllocation {
sellingPlan {
name
}
}
#/***********************************************/
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Adding sellingPlanAllocation here.

@blittle blittle force-pushed the bl-fix-optimistic-cart-types-2 branch 2 times, most recently from b8c908a to a67a4dd Compare July 12, 2024 20:25
@blittle
Copy link
Contributor Author

blittle commented Jul 12, 2024

/snapit

Copy link
Contributor

🫰✨ Thanks @blittle! Your snapshot has been published to npm.

Test the snapshot by updating your package.json with the newly published version:

"@shopify/hydrogen": "0.0.0-snapshot-20240712202726"

@blittle blittle force-pushed the bl-fix-optimistic-cart-types-2 branch from a0a9965 to d4e17c7 Compare July 29, 2024 18:48
@blittle blittle requested a review from frandiox July 29, 2024 18:54
@merrickread
Copy link

I've experienced this as well! Would love to see it come in the next release :)

@blittle blittle merged commit dfb9be7 into main Jul 31, 2024
13 checks passed
@blittle blittle deleted the bl-fix-optimistic-cart-types-2 branch July 31, 2024 15:04
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