Account projections example
A simple and elegant view of getting current account details and associated transactions.
Installation
Open your node terminal.
# Clone project from GitHub
git clone \
https://github.com/balamuralisrinivasan/acct-projections
# Install dependencies
npm install --save
# Fire-up the engine
npm start
You are good to go; access the console is here and the API is published under the URI http://localhost:8080/graphql.
Seed Data
The project already has the seed data under ./test/*.js
for:
- Accounts (
test-data/accounts.json
) - Transactions (
test-data/transactions.json
)
You can regenerate this data - althrough not required - using the command:
node seed/seed_loader.js
The seed_loader.js
uses the fantastic casual framework to generate awesome test data.
Advanced stuff
Generate lots and lots of data with the MongoDB backend; assure your backend is started, for example:
mongod --dbpath=./mongodb-data
Now, generate using the seed_loader tool the desired dataset:
node seed/seed_loader.js --dataStorageType=mongodb \
--mongodbUrl=mongodb://localhost:27017/acctprojection \
--nrOfAccounts=1000 \
--nrOfTransPerAccount=10000 \
--transHistoryStartYear=2008
Usage
Explore and discover by playing with queries. A sample query is here below. A basic query to get only the account details.
query myAccount {
currentAccount(account: {iban: "IE89CITI73317996533808"}) {
name
iban
availableBalance
mailingAddress {
city
postalCode
address
countryCode
}
}
}
Retreive nested transactions posted using the same account. The transactions can be filtered for transactions posted on or later than startDate as given below.
query myAccount {
currentAccount(account: {iban: "IE89CITI73317996533808"}) {
name
iban
availableBalance
mailingAddress {
city
postalCode
address
countryCode
}
transactions(dateRange: {
startDate: "2016-10-01"
}) {
valueDate
acctRef
acctBalance
partyInf
{
account
bankReferenceNo
instrumentID
billingAddress
{
address
}
}
amount
}
}
}
Now add an end date and narrow down the filter.
query myAccount {
currentAccount(account: {iban: "IE89CITI73317996533808"}) {
name
iban
availableBalance
mailingAddress {
city
postalCode
address
countryCode
}
transactions(dateRange: {
startDate: "2016-10-01",
endDate: "2016-12-01"
}) {
valueDate
acctRef
acctBalance
partyInf
{
account
bankReferenceNo
instrumentID
billingAddress
{
address
}
}
amount
}
}
}
Functional test automation
A sample scenario has been automated using jest:
Run your QA server which will just run the API end point and not graphiQL.
npm run-script qaserver
Run the tests which will iterate through all js files in tests folder and run as a single Test Suite.
npm test