Take a look at how the Ballerina programming makes it a trivial task to implement a feature-rich GraphQL scenario using its in-built services functionality.

Introduction

GraphQL has become a prominent technology in implementing data APIs. It provides a convenient and intuitive approach for querying data. Let’s look at a sample use case using the  Ballerina programming language and see how GraphQL compares to other traditional approaches such as implementing REST-style HTTP APIs.

Use Case: E-commerce Data Query

Let’s take a typical e-commerce scenario of processing orders in an online store. The entity-relationship diagram below shows a typical representation that can be used in a relational database. This is of course a simplified representation of a real-life implementation.

One approach for exposing such a data set would be to create a service with operations for each database table. This would be similar to the following.

  • getOrder(id): OrderInfo
  • getCustomer(id): CustomerInfo
  • getShipper(id): ShipperInfo

#graphql #ballerina #microservice

GraphQL Made Easy With Ballerina
1.25 GEEK