feat: add a dedicated Storefront GraphQL client - #29
Draft
0xtlt wants to merge 3 commits into
Draft
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.
Summary
ShopifyStorefrontclient with tokenless, public-token, and private-token authenticationStorefrontRequestContextShopify, so invalid Admin/Storefront combinations fail at compile timeWhy
The client currently hardcodes the Admin GraphQL endpoint, so it cannot be used for custom storefront workloads. Storefront requests need a different URL and different authentication headers.
Private-token requests made by a server on behalf of buyer traffic must also forward
Shopify-Storefront-Buyer-IP. Keeping that value in a per-request context prevents buyer IPs from leaking across concurrent requests. Static builds and other non-buyer traffic can continue to use the regular GraphQL methods.A separate public type keeps invalid Admin/Storefront combinations out of the API: callers get a compile-time error instead of a runtime guard when attempting an Admin-only operation on a Storefront client.
Closes #22.
Developer impact
Existing
Shopify,Shopify::new, andShopifyConfigusage remains unchanged. Storefront clients opt in throughShopifyStorefront::new,StorefrontAuth, andStorefrontConfig. Buyer-originated private-token calls use the corresponding*_with_contextmethod.Validation
cargo test --all-featurescargo test --no-default-featuresgraphql-clientcargo clippy --all-targets --all-features -- -D warningscargo fmt -- --checkRUSTDOCFLAGS="-D warnings" cargo doc --no-deps --document-private-items --all-features