GraphQL BaaS – Backend as a Service

GraphQL BaaS – Backend as a Service
graphql-baas

Creating the next big mobile app is an expensive and time-consuming process. Taking your idea to life demands time and energy, and, financial resources. I will explore how new technologies like GraphQL will reduce your time to market and speed up your app development process.

This article will explain the benefits of using GraphQL together with Backend as a Service platform, and here is a summary of what you will learn:

  • GraphQL overview
  • What is GraphQL?
  • GraphQL Schema
  • GraphQL versus REST
  • Why use GraphQL?
  • Benefits/Downsides of GraphQL
  • When using GraphQL?
  • BaaS and GraphQL working together
  • GraphQL BaaS providers

GraphQL overview

Many of you have heard of GraphQL for some time, but not yet knowing what it is and why we should consider it into your development stack. Maybe it is an excellent choice for your project.

Shall we understand a little more?

GraphQL started on Facebook, as follows:

  • Displaying a list of posts required access to an API.
  • Each post had to show a list of users who liked it.
  • Each user object had to show a name, profile photo, link to the profile if the user is already your friend, etc.

At least that’s what we can see when we access Facebook through the browser. But when we’re in the mobile app, we don’t have all this information. What we have is a list of likes and the link to their profile.

But how to prevent server sending unwanted data?

This simple measure will make the mobile apps work faster, save data transfer for mobile users, and save millions of dollars in data transfer out costs to Facebook. Rather than having to create an API for each different data structure and manually make queries for each database and then gather the data, Facebook decided to use a different approach.  Create a new query language to solve this problem. This query language is GraphQL and allows developers to specify what they need every time a query is performed.

GraphQL is NOT…

  • GraphQL is not a database.
  • GraphQL is not a substitute for SQL.
  • GraphQL is not a server-side tool.
  • GraphQL is not React specific.

What is GraphQL?

Here is the definition from GraphQL Organization.

GraphQL is a query language for your API, and a server-side runtime for executing queries by using a type system you define for your data. GraphQL isn’t tied to any specific database or storage engine and is instead backed by your existing code and data.

Mutations, Queries, and Subscriptions

The GraphQL schema is straightforward and formed with 03 main types that support distinct sets of actions:

  • Mutations are used to create, update, and delete data.
  • Queries are utilized by the client to request the data from the backend.
  • Subscriptions are a way to build and have a real-time relationship with the server.

GraphQL vs. REST

A good way to understand GraphQL is to say that it is between SOAP and REST, taking pieces from each one. Here is a quick overview of the main differences between GrapQL and REST APIs.

Description GraphQL REST
Endpoint Single Multiple
HTTP Semantics Query, Mutation, Subscription GET, POST, PUT, DELETE
Error Codes Single 200 status codes Multiple status codes
Cacheable No Yes
Stateless Yes Yes
Overfetching No Yes
Underfetching No Yes

Why use GraphQL?

GraphQL solves several problems NOT addressed by REST, including:

  • API versioning
  • Overfetching/Underfetching
  • Slow performance of large mobile apps

Advantages and Disadvantages of GraphQL

All right! Now you understand what is GraphQL and why Facebook created it, but what are the benefits to your app? Here is a list of how GraphQL will benefit you.

Benefits of GraphQL

  • Reduce data transfer costs, both on the server-side (transfer out) and on client-side (4G bandwidth).
  • Guarantee faster response times even on slow connections.
  • Faster load times for your mobile app.
  • Simplicity leads to a more stable backend.

Drawbacks of GraphQL

  • Learning curve. You already know REST and will need to learn GraphQL.
  • Caching. It’s harder with GraphQL.
  • Queries always return status code 200.

When to use a GraphQL?

Here are some use cases that you will benefit using GraphQL.

  • Projects that require to process data quickly.
  • Applications with high data throughput.
  • Projects that need to recover information from multiple databases.
  • Collect data from different stacks.
  • Integration with 3rd party services.
  • Multiplatform implementations (web, mobile, IoT)

Deploying GraphQL with a BaaS

Using a BaaS will provide you the following benefits:

  • Let you concentrate on your core product without reinventing the wheel.
  • Automation regarding managing databases, running infrastructure, etc.
  • Reduce the total cost of development.

You will put together the advantages of a backend as a service with the flexibility and simplicity GraphQL delivers. This setup allows a developer to create their schemas and automatically deploy them on a ready-to-use infrastructure environment.


GraphQL BaaS providers

Here is a list of backend as a services providers that support GraphQL. Some companies will deliver managed GraphQL backend hosting. The others will only provide self-hosting options.

Back4App

Summary: Easy-to-use, flexible, and scalable backend based on GraphQL and Parse open-source.

Production Ready: Yes

Pricing: Free plan available. Paid plans start at $5/month.

Database Types: MongoDB and Postgres

Hosting Options: Cloud hosting with Back4App (shared hosting and private instances) or AWS, Azure, Google Cloud

Parse

Summary: Open-source NodeJS backend framework.

Production Ready: No.

Pricing: Free download only. No support or paid plans available.

Database Types: MongoDB and Postgres

Hosting Options: It can pretty much be deployed in any cloud. Standard options are AWS, Digital Ocean, and Azure.

AWS Amplify

Summary: A declarative JavaScript library for application development using cloud services.

Production Ready: Yes.

Pricing: Pay by the use at AWS. Free download option available.

Database Types: MongoDB and Postgres

Hosting Options: It can pretty much be deployed in any cloud. Common options are AWS, Digital Ocean, and Azure.

Hasura

Summary: Instant Realtime GraphQL on Postgres

Production Ready: Yes

Pricing: Free plan available. Paid plans start at $99/month.

Database Types: Postgres

Hosting Options: Integrated with Heroku. Deployment is also available at AWS, Azure, and Google Cloud.

GraphCool

Summary: Open-source and self-hosted backend-as-a-service to develop serverless GraphQL backends.

Production Ready: Yes

Pricing: Free plan available. Paid plans start at $35/month.

Database Types: MySQL, Aurora.

Hosting Options: GraphCool cloud hosting or self-hosting with Docker.

Prisma

Summary: This is a database abstraction layer that turns your databases into GraphQL APIs with creating, read, update, and delete procedures and realtime capacities.

Production Ready: Yes

Pricing: Free plans available. Paid plans start at $15/user.

Database Types: MySQL, Postgres, and MongoDB.

 


Leave a reply

Your email address will not be published.