/boot-graphql-playground

Code to implement GraphQL API using Spring GraphQL, including exception handling, security, GraphQL extensions, unit and integration tests

Primary LanguageJava

Spring GraphQL Playground

This repository contains the demo code for implementing a GraphQL API using the Spring GraphQL library. This implementation is used to learn the following GraphQL concepts:

Getting started

  • Start the application from the console entering the command from the root of the project

    ./mvnw spring-boot:run
  • Open the browser and access the url http://localhost:8080/graphiql to start the GraphiQL in-browser IDE

    • To get the list of Transactions for the accountId 1 use the following query
     query getTransanctions($input: TransactionSearchInput) {
       transactions(input: $input) {
         transactionId
         accountId
         customerId
         amount
         balance
         description
         transactionDateTime
      }
    }
    

    with the following variables defined in the Query Variables section

      {    
         "input": {
           "accountId": 1,
           "customerId": null
         }
      }
    

    as seen in the screenshot sample below:

    GraphQL API for query transactions

Domain

The domain for this demo represents a very minimal Banking Account Transactions scenario.

Domain Description
Customer Bank Account Holder, includes personal details such as First Name, Last Name etc
Account Bank Account, many-to-many relationship with the Customer domain. includes the type of Account (SAVINGS, CHECKING) and the latest balance amount
Transaction Transaction history for a given account/customer. Includes details such as type of transaction(DEPOSIT,WITHDRAW), amount, updated balance, transaction timestamp etc.