
Do you want to know how to get store currency information using GraphQL Query in Magento 2?
In this Magento 2 GraphQL Tutorial, We will show how to get store currency information using GraphQL Query in Magento 2. We will use the {currency} query to get information about a store’s currency configuration.
Let’s start!
Get Store’s Currency Configuration Query:
The {currency} query can returns store’s currency information. The following call returns all base details of a store’s currency configuration.
currency { base_currency_code base_currency_symbol default_display_currency_code default_display_currency_symbol available_currency_codes exchange_rates { currency_to rate } }
Output:
{ "data": { "currency": { "base_currency_code": "USD", "base_currency_symbol": "$", "default_display_currency_code": "USD", "default_display_currency_symbol": "$", "available_currency_codes": [ "EUR", "USD" ], "exchange_rates": [ { "currency_to": "EUR", "rate": 0.7067 }, { "currency_to": "USD", "rate": 1 } ] } } }
The following query provides currency information for an instance of Magento that is configured for multiple currencies, USD and EUR. The default (base) currency for the store is US Dollar (USD). The response includes a list of currencies in the available_currency_codes attribute as well as a set of exchange rates.
How to Get Currency Information Using GraphQL in Magento 2 Click To TweetYou can use ChromeiQL tool to test and run GraphQL Query in Magento 2.
If you liked this tutorial, then please subscribe to our Newsletter for Magento tutorials. You can also find us on Twitter and Facebook. If you have any problem or would like to add to the discussion, leave a comment below!