Skip to content

felipelincoln/graph-banking

Repository files navigation

GraphBanking API

Docs status Build status Coverage status

A simple banking app implemented with GraphQL.

Introduction

This app exposes a few GraphQL endpoints to manipulate a sandbox database that simulates a bank. It is possible to open a new account, fetch account information and make currency transactions between two accounts.

The documentation for these features can be found here.

Consuming the API.

Since this is deployed to a Heroku free plan, the server may take some time to wakeup 😴.

Usage Examples

Creating an account using the openAccount mutation

mutation {
  openAccount(currentBalance: 45.5){
    uuid
    currentBalance
  }
}

yields the following .json response.

{
  "data": {
    "openAccount": {
      "currentBalance": 45.5,
      "uuid": "b135e3c2-3e95-47ea-b781-fcebd487dc2e"
    }
  }
}

Using the account query on some previously created account 4533be1c-ebc1-4bfa-aab7-643084e58b44

{
  account(uuid: "4533be1c-ebc1-4bfa-aab7-643084e58b44"){
    uuid
    currentBalance
  }
}

it is possible to retrieve the current balance.

{
  "data": {
    "account": {
      "currentBalance": 0,
      "uuid": "4533be1c-ebc1-4bfa-aab7-643084e58b44"
    }
  }
}

Having two uuid it is possible to transfer money between them using the transferMoney mutation.

mutation {
  transferMoney(
    sender: "b135e3c2-3e95-47ea-b781-fcebd487dc2e"
    address: "4533be1c-ebc1-4bfa-aab7-643084e58b44"
    amount: 32
  ) {
    address
    amount
    uuid
    when
  }
}

And the response is the transaction information.

{
  "data": {
    "transferMoney": {
      "address": "4533be1c-ebc1-4bfa-aab7-643084e58b44",
      "amount": 32,
      "uuid": "17fad487-f31b-42c7-8658-9eee447ae4ce",
      "when": "2020-11-21 08:52:45Z"
    }
  }
}

Running locally

This app runs inside a docker container. We provide a guide on how to get it running on your machine here