Skip to content

GraphQL queries

Accounts

You can list all your accounts. Note that the query contains the list of fields that we want to get in the response. In REST API, you would usually get all the fields with no option to choose.

query Accounts {
    accounts {
        id
        accountName
        balance
        iban
    }
}

A positive response should look like this:

{
    "data": {
        "accounts": [
            {
                "id": 177,
                "accountName": "Charles Goose - Business",
                "balance": 50000.0,
                "iban": "GB85SASL44193852448864"
            },
            {
                "id": 178,
                "accountName": "Charles Goose - Personal",
                "balance": 36365.0,
                "iban": "GB07LIAP90710553025752"
            }
        ]
    }
}

Try removing some of the fields from the query and see how the response changes.

Accounts with transactions

As the GraphQL name suggests, you can use it to get linked data. For example, you can get all your accounts with their transactions.

Here comes the strength of GraphQL. Instead of qeurying the accounts and then querying the transactions for each account, you can get all the data in one request.👍

query AccountsWithTransactions {
    accounts {
        id
        accountName
        balance
        iban
        transactions {id amount note}
    }
}

We can see there are no transactions on the business account, but there are two transactions on the personal account:

{
    "data": {
        "accounts": [
            {
                "id": 177,
                "accountName": "Charles Goose - Business",
                "balance": 50000.0,
                "iban": "GB85SASL44193852448864",
                "transactions": []
            },
            {
                "id": 178,
                "accountName": "Charles Goose - Personal",
                "balance": 36365.0,
                "iban": "GB07LIAP90710553025752",
                "transactions": [
                    {
                        "id": 70,
                        "amount": 570.0,
                        "note": "Flat rent"
                    },
                    {
                        "id": 69,
                        "amount": 65.0,
                        "note": "Food"
                    }
                ]
            }
        ]
    }
}

Transactions

Similarly, you can list all your transactions regardless of the account.

query Transactions {
    transactions {
        id
        direction
        currency
        amount
        note
        counterpartyIban
        counterpartyName
        createdAt
    }
}

And you can list them with the account information linked to them. So, we can see that data can be linked in both directions if needed.

query TransactionsWithAccounts {
    transactions {
        id
        amount
        note
        counterpartyIban
        counterpartyName
        account {id accountName balance}
    }
}

Such query provides a response:

{
    "data": {
        "transactions": [
            {
                "id": 69,
                "amount": 65.0,
                "note": "Food",
                "counterpartyIban": "GB78LXCT41632963612706",
                "counterpartyName": "Susan White",
                "account": {
                    "id": 178,
                    "accountName": "Charles Goose - Personal",
                    "balance": 36365.0
                }
            },
            {
                "id": 70,
                "amount": 570.0,
                "note": "Flat rent",
                "counterpartyIban": "GB78LXCT41632963612706",
                "counterpartyName": "Susan White",
                "account": {
                    "id": 178,
                    "accountName": "Charles Goose - Personal",
                    "balance": 36365.0
                }
            }
        ]
    }
}

That's for querying data. Now let's see how to change it.