GraphQL tools & libraries
Tomek Poniatowicz
Posted on August 28, 2020
If you’re interested in a writeup about GraphQL itself head on over here. In this piece, we’ll take a look at some of the many handy GraphQL tools that make using it even more worthwhile. Bear in mind there’s quite a few of them so we’re not going to get through the lot of them in one go.
Prisma
As mentioned before, working with GraphQL will require you to set up a database. Well, there’s also BaaS so you can outsource it, but what if you don't want to? This is where Prisma comes in, it’s a clever middle ground between doing it yourself and outsourcing.
Prisma is an ORM library that lets you interact with the database from the server in the language you choose. So if you want to write to your MySQL database you don't have to do it in SQL, Prima lets you do it in Python, JavaScript or some other language you prefer.
You might think: "Yeah, but that’s just what a regular ORM library does". True, but Prisma comes with a few added functions:
- database agnostic: Prisma currently supports MySQL, PostgreSQL, MariaDB, SQLite, and AWS Aurora, with more to come soon,
- supports TypeScript, JavaScript, Flow, and Go,
- provides premade basic CRUD queries.
Source: prisma.io
Relay
Relay is a JavaScript framework created by Facebook for fetching and managing GraphQL data. Relay is supposed to be the go-to tool for GraphQL users with a focus on validating and optimizing your code. Another focal point is being a bridge between GraphQL and React. Relay lets you set up your data requirements using GraphQL and then it will handle the fetching, collecting queries into network requests to get you exactly what you wanted.
Relay is composed of three main loosely coupled modules:
- Relay Compiler: a GraphQL compiler that analyzes, validates, and optimizes GraphQL in your code.
- Relay Runtime: a full-featured GraphQL runtime for building higher level client APIs
- Relay/React: a product API that integrates Relay Runtime with React
Source: relay.dev
Apollo
The APOLLO platform is an implementation of GraphQL that transfers data from the server to your UI. Apollo-client is a comprehensive state management library for JavaScript that lets you manage both local and remote data with GraphQL. The aim is to enable you to build UI components that fetch data via GraphQL. Apollo-server is a quick way for building an API for GraphQL using data from any source by using a spec-compliant server that can be queried from any GraphQL client, including the Apollo-client.
Let’s look at the Apollo-client features:
- a declarative approach to data fetching, all the logic for retrieving data, tracking, loading and uploading it to the UI is contained in a single query,
- designed for modern React, the Apollo client takes advantage of the latest React features such as hooks,
- adaptable, can be dropped into any JavaScript app seamlessly,
- universally compatible, can be used with any GraphQL API.
Source: apollographql.com
Hasura
Hasura is a GraphQL engine that boasts its high speed and performance. It gives you instant realtime GraphQL APIs on any Postgres database, with remote schemas for business logic and webhook triggers on database events.
The focus is to help quickly build GraphQL apps backed by Postgres or use Postgres to help move existing apps to GraphQLs:
- realtime, convert GraphQL queries to live queries via subscriptions,
- fast and instantly ready to use, simply point it to a Postgres database and instantly get a GraphQL API,
- powerful queries, Hasura has built-in filtering, pagination, pattern search, bulk insert, update, delete mutations,
- fairly new and in rapid development with a bunch of features coming soon.
Source: hasura.io
URQL
urql is a versatile and highly adaptable GraphQL client by Formidable labs. It uses React hooks and components and intends to be a lighter client than the others. A versatile tool that you can customize to fit your needs and fine-tune as you get further along working with GraphQL.
The aim is hitting a middle ground, keeping it somewhat simple while also being able to handle complex assignments by:
- performance and functionality, significantly lighter than other clients,
- customization, the client provides a few default Exchanges, easily customizable code that handles interactions with the API, app or framework,
- instantly ready to use, urql is basically ready for work right off the bat and does not require extensive configuration like some other clients,
- named after an iconic sitcom character.
Source: formidable.com/urql/
Well, that’s it for the first look at GraphQL tools. Remember that that’s only five of them and GraphQL has plenty of other tools to choose from. So if I missed your favorite, just mention it in the comments and stay tuned for the next parts!
A guest blog post for GraphQL Editor blog by Michal Tyszkiewicz
Want to speed up your GraphQL schema development?
GraphQL Editor is a supportive tool for both advanced GraphQL users as well as those taking their first steps with GraphQL APIs. Our all-in-one development environment for GraphQL will help you build, manage & deploy your GraphQL API much faster. Try GraphQL Editor for free!
Posted on August 28, 2020
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.