Skip to content
Developerhome

Example GraphQL queries for currency rates

  Less than to read

Available currencies

This query provides the list of currencies available sorted by alphabetical order for the first 100.

{
  xtremX3MasterData {
    currency {
      query(filter: "{euroDate: {_lte: '2021-07-13' }}", first: 100) {
        edges {
          node {
            code
            isEuro
            euroDate
            localizedDescription
            localizedShortDescription
          }
        }
      }
    }
  }
}

Last currency exchange for a given source company

You can use this query to inquire about:

  • The latest exchange rate at a given date
  • Several currencies in connection with a base currency for a given rate type and sorted by alphabetical order
{
  xtremX3MasterData {
    currency {
      query(filter: "{code: 'EUR'}") {
        edges {
          node {
            code
            isEuro
            euroDate
            lastCurrencyRate {
              query(filter: "{rateDate: {_lte: '2021-07-13' }, rateType: 1}") {
                edges {
                  node {
                    rateType
                    sourceCurrency
                    destinationCurrency
                    rateDate
                    rate
                    inverseRate
                    divisor
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}

Mutations

The following mutations are currently available using the GraphQL API for the currency-rate.ts nodes.

Three actions are possible with the mutation mode. You can create, update and delete a currency rate.

Create a currency rate

To create a currency rate for existing currencies, enter a value for the following properties.

mutation {
  xtremX3MasterData {
    currencyRate {
      create(rateType: 1, sourceCurrency: "EUR", destinationCurrency: "USD", rateDate: "2021-09-07", rate: 0.611, amount: 1.2)
    }
  }
}

Update a currency rate

You can also easily edit an existing currency rate. Use the update instruction and edit the two last properties: rate and amount.

mutation {
  xtremX3MasterData {
    currencyRate {
      update(rateType: 1, sourceCurrency: "EUR", destinationCurrency: "USD", rateDate: "2021-09-07", rate: 0.611, amount: 1.2)
    }
  }
}

Delete a currency rate

You can finally delete an existing currency rate. Use the delete instruction and fill in the key properties.

mutation {
  xtremX3MasterData {
    currencyRate {
      delete(rateType: 1, sourceCurrency: "EUR", destinationCurrency: "USD", rateDate: "2021-09-07")
    }
  }
}