Add getVariantsByIds: variant-level presentment prices - #152
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
ShopifyStore.getVariantsByIds— a variant-level lookup that returns presentment prices.Why
There is currently no way to ask this package for the price of a known set of variants in a given market.
getProductsByIdslooks like the right call, but its query matches... on Product.nodes(ids:)is polymorphic, so passing variant gids returns empty entries — silently, not as an error.getProductsQuerynestsproducts(first: 250)→variants(first: 250)→sellingPlanAllocations(first: 250), pluscollections(250),images(250)andmedia(250). Against a real catalogue that is orders of magnitude past the Storefront API's 1000-point query-cost limit, and it comes back as a bareInternal error. Looks like something went wrong on our end.with a request id rather than a cost message.What
get_variants_by_ids.dartselects no nested connections, so the query costs roughly one point per id. It runs under@inContext(country: $country)like the other queries and is fedShopifyLocalization.countryCode, so the prices are the presentment prices for the selected market. Ids that don't resolve to a variant are skipped.The selected fields are exactly what
ProductVariant.fromJsonneeds, so the method returns the package's own model rather than a bespoke shape.Note on stacking
This branch sits on top of #150 and #151, so the diff here includes both. Happy to rebase onto whatever lands first, or to split it if you'd rather take this one on its own.
🤖 Generated with Claude Code