17th Jul 2018

Getting started with Koa and GraphQL


Author

Suroor Wijdan

Founder & CEO

4 min readJavaScriptBackend Engineering
4 min readJavaScriptBackend Engineering

What is Koa?

Koa is a new framework that is created by the team behind the popular Express.js framework. Koa is a javascript futuristic framework and uses generators which allow the framework to exist without using any callbacks. Generators make the code really much more readable and greatly improves app level error-handling.

The team behind Koa has kept the framework as much independent as it can be without bundling too many middlewares for different tasks. At the same time, it has many inbuilt methods that vastly improve the way we write servers.

Koa GraphQL Boilerplate:

We at Xencov created a simplistic and slightly opinionated Boilerplate that gets you started with writing performant APIs without the need of setting up a project from scratch.

The boilerplate can be seen here: https://github.com/Xencov/koa-graphql-boilerplate

What is included in the boilerplate?

  1. Koa
  2. GraphQL
  3. Mongoose (MongoDB)
  4. JWT (Authentication) and other supporting modules that you can check on the GitHub repo.

How does GraphQL improves my API?

GraphQL may seem like an overhead initially but the real power lies when you start utilizing the API on your front-end whether its a mobile or a web app. GraphQL gives the power back to the client to only ask for the data it needs and nothing else from the API.

Lets take an example, you build an API for the home screen of your mobile app and the API is successfully integrated by the mobile app developer. Now the management wants to change the UI or add a new widget which needs some more data about the user. In a normal scenario, that would require the backend developer to make a change in the API to send the additional required data back to the client.

When using GraphQL, this change and additional development time could be saved because the client already has the power to get whatever data that is needed. You see how time-saving and easy that can be in scenarios when you have to maintain versions of your APIs due to such changes.

We will learn about the challenges that we faced in GraphQL in another blog.

Let me know if you have any feedback on the boilerplate. Feel free to submit a pull request to improve any aspect of it.

We bring the best in technology combined with an Agile process which results in higher efficiency and desired results for our clients.

Talk to us!

LATEST FROM OUR BLOG

Building a Facebook Echo-Bot in Python

Gartner estimates that by 2020, chatbots will be handling 85 percent of customer-service interactions; they are already handling about 30 percent of transactions now.

Read more

How to Send an Email from Flutter - SMS App Part 3

In this blog, we will see how we can send emails from our flutter application using mailgun credentials. This post is in continuation of the Flutter SMS app series.

Read more

How To Listen for SMS using Flutter - SMS App Part 2

In continuation with the previous blog, we would continue to build our new basic SMS app using Flutter. In this blog, we would see how we can add the functionality of listening for incoming SMS messages on the device.

Read more