-
Notifications
You must be signed in to change notification settings - Fork 263
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
Using @inContext with queries/mutations #884
Comments
Since the Buy SDK doesn't work with this at all I ended up rewriting all calls to use raw GraphQL queries. |
@sjelfull Were you able to use @incontext directives using the same gql library js-buy-sdk uses? It seems like they support directives but not on the root query object..... |
I ended up using I copied all the .graphql files, added the function replaceContextCountry(query) {
query.definitions[0].directives[0].arguments[0].value.value = regionIsoCode
return query
} |
@Adu88 Thank you! I've actually been working on modifying |
@JeffJassky Here you go i created a repo with the file i use for the buy-sdk client when i make queries to shopify. https://github.com/Adu88/buy-sdk. Feel free to clone it and see the updates/differences i wrote above. Also from above it's missing this: and of course when you call that method you've modified from the client you need to call it with your internationalDirective like this : |
@Adu88 Based on your code, I fixed some issues that occourred when the internationalizationDirective was not provided. |
Feature details
Is your feature request related to a problem? Please describe.
Since the removal of presentment prices and adding the
@inContext
directive, it seems like multi-currency behaviour is not consistent or helpful in the Buy SDK, meaning you have to run custom queries somehow.My current problem that I'm trying to solve: I want to add multi-currency support, and I want to see the cart and line items in the currently selected currency.
Step 1 was figuring out how to set the currency on the cart. After a few rounds and touching the deprecated
presentmentCurrencyCode
, I foundbuyerIdentity.countryCode
which gives me the correct currency on the cart, meaning the total will show in the associated currency.However, the line item totals/prices is NOT returned in the correct currency - they use the default currency.
It was kind of hard to find the place that explains why this is - why would the cart show in two different currencies? My current understanding is that I need to use the new
@inContext
directive to ALSO get the line items in the correct currency.Describe the solution you'd like
Do you plan to add support for the
@inContext
directive in the short term, or could you help with a example that shows how to get the cart and all prices/totals in the same currency?Describe alternatives you've considered
I have considered trying to do the queries manually, but it requires a bit of a lift to do this since we use the JS SDK everywhere.
Additional context
Sample response:
The text was updated successfully, but these errors were encountered: