Magento 2 How to get currency in GraphQL

We will explain you, how to get currency using GraphQL, Use the currency query to return information about the store’s currency configuration.

Syntax

Copy
{currency {Currency}}

The following query returns the currency for the current instance of Magento:

Request

Copy
{
    currency {
        base_currency_code
        base_currency_symbol
        default_display_currency_code
        default_display_currency_symbol
        available_currency_codes
        exchange_rates {
            currency_to
            rate
        }
    }
}

Response

Copy
{
  "data": {
    "currency": {
      "base_currency_code": "USD",
      "base_currency_symbol": "$",
      "default_display_currency_code": "USD",
      "default_display_currency_symbol": "$",
      "available_currency_codes": [
        "USD",
        "EUR"
      ],
      "exchange_rates": [
        {
          "currency_to": "USD",
          "rate": 1
        },
        {
          "currency_to": "EUR",
          "rate": 0.7067
        }
      ]
    }
  }
}

That's it!!

If you are looking for more GraphQL solutions then check out our another article which is List of GraphQL Queries and Mutations for Magento 2.

I hope this article helps you to find what you were looking for.

Bookmark it for your future reference. Do comment below if you have any other questions on that.

P.S. Do share this article with your team.




Search
Recent Posts
    Tags
    Newsletter
    SocialFollow on Twitter
    Visit now!