Building a Serverless GraphQL API For Any Datasource With StepZen

Rate this content
Bookmark

Want to get started with building a GraphQL server but have no idea where to begin? Every (frontend) developer asks for a GraphQL API but often lacks the backend knowledge to create a performant one. There are many different flavours in creating the perfect GraphQL server, ranging from schema-first to code-first or even auto-generated solutions.

In this interactive workshop, you will learn about building a serverless GraphQL API using StepZen. With StepZen, you can create a GraphQL for any data source (SQL, NoSQL & REST) and even other GraphQL APIs within minutes. And even handle more complicated use cases such as authentication and deployment. Using little code, you'll get to combine different data sources in one fully performant API that you can use in your applications from day one.

Table of contents:
- What is StepZen?
- Connecting to a data source (SQL, NoSQL & REST)
- Using custom directives
- Handle sequence flows
- Deployment

Roy Derks
Roy Derks
75 min
02 Dec, 2021

Comments

Sign in or register to post your comment.

Video Summary and Transcription

Today's workshop is about building a serverless GraphQL API using StepZen. It covers the code-first and schema-first approaches, connecting multiple data sources, merging data from different endpoints, and using StepZen's sequences to combine data. The workshop also highlights the importance of understanding StepZen and GraphQL for building scalable GraphQL servers.

Available in Español

1. Introduction to Serverless GraphQL API Workshop

Short description:

Today's workshop will be about building a serverless GraphQL API using a tool called Stepsen. You can create a GraphQL API for any data source, such as MySQL or Postgres. If you don't have Docker, ng-work can be used to create a remote port to your local system. If you don't have experience with GraphQL, that's fine. I will do a short presentation, explain the assignments, show you where to find the code, and how to run the Docker. Then you can start building a GraphQL API. We will have breakout rooms for smaller groups to ask questions. Use Zoom for general questions and Discord for technical questions or sharing links.

Hello, everyone. Thanks for joining. So, I see you already shared my screen. I believe everyone can also hear me. So, that's good.

So, today's workshop will be about building a serverless GraphQL API and we're going to do this using a tool called Stepsen. And with this tool, you can create a GraphQL API for any data source. So, I don't know if you saw the prerequisites for today's workshop. So, if you want to work with MySQL or Postgres today, then you will need to have a Docker running as well. So, if you don't have Docker on your machine just yet, now's a good time to install it. And also, ng-work. That's something we'll be using to create a remote port to your local system, because how Stepsen works, it's going to take remote connections. So, that can be your database. It can be an existing rest API, existing GraphQL API and build a serverless GraphQL API on top of those sources. So, that's why we need ng-work as well in order to expose the, all the local database you're running with Docker to remote network. But it's up to you if you don't have Docker installed, or maybe you don't know how to use Docker, which is not actually needed. You don't need to understand how Docker works. You just need to install it and run one command. And then you should be able to run the database in your own system. But if you don't want to use Docker, you don't want to use a database, then you can use a rest API, which I'll also provide you with later on once we go to the assignments.

So, that's for starters. I hope you're all looking forward to this, to this workshop. If you don't have any experience with GraphQL yet, then that's also perfectly fine. Please let me know in the chat. So, I have an idea how much stuff I should explain and how much I shouldn't explain. That will be useful to everyone, I think. So, then we have more time to actually build some code. And then I have more time to help you with any questions you have. So, if you GraphQL yet, please use Discord or the chat to ask questions during this presentation. So, that will also be the format. I will do a short presentation first. I think it will be roughly 20, 25 minutes. Then I will explain the assignments. I will show you where to find the code we'll be using today. I'll show you how to run the Docker. And then you can start building a GraphQL API. And then I'll probably put you in, let's see, we're around 20 people here. I'll probably put you in four or five breakout rooms. So, you have smaller groups to ask questions to each other as well. And I can hop on and hop off to different breakout rooms. So, I hope that's all clear. If not, then just use the chat and Zoom to ask questions. Maybe for more technical questions, it's easier to use the Discord because then people can reply, and we won't lose the answers. That's a nice feature of having the Discord. It's easier to send links there because you're already in a browser. So, use Zoom if you have any questions regarding the things I'm telling you right now, and use Discord if you have any technical questions or want to share links with other people.

2. Building a Serverless GraphQL API with StepZen

Short description:

Today's workshop will be about building a Serverless GraphQL API using StepZen on top of your existing data sources. Building a GraphQL API is easy to get started, but scalability can be challenging. This talk will cover GraphQL servers, creating them, and scalability. StepZen is a tool that allows you to create GraphQL APIs on top of existing data sources. There are multiple reasons to build a GraphQL server, such as optimizing client requests, working with microservices, and wrapping legacy services. There are multiple ways to create GraphQL servers, including building from scratch or using libraries like Prisma, Apollo, or StepZen.

Then a Discord might be easier. So, what is today about? So, we're going to be building a Serverless GraphQL API using StepZen on top of your existing data sources, and you probably all have different reasons to join this workshop, and maybe if we have time later on, we can talk about your projects a bit as well, probably when I put you in your breakout rooms.

So, who's this talk for? And this workshop as well. So, what I often see happening, and I've built lots of GraphQL APIs in my time. I started with GraphQL in 2016 when it became a public library, and the first thing I always see when building GraphQL APIs, it's super easy to get started. If you want, you have a GraphQL API running with some things like Apollo or Prisma or any other GraphQL library out there, basically, within a couple of hours, you can attach your existing data sources, you can attach REST APIs, or GraphQL APIs, and it's super easy to build that first GraphQL API. But then once you start scaling things, I often find out, and I heard this all the time from different engineering teams as well, it's pretty hard to scale a GraphQL API if you don't have the whole knowledge about GraphQL, if you don't know how the graphs work, if you don't know how data is related to each other. So building a GraphQL API is probably easy, you build your schema, you build your first five resolvers. But after that, things get tricky because that's where you actually need the GraphQL in-depth knowledge, where you need to knowledge about databases, you need to knowledge about underlying systems. And so scalability for GraphQL APIs is always tricky. If you look on the internet, there's tons of benchmarks for existing GraphQL libraries, GraphQL server libraries, find out which one is the fastest. And those are basically up to the GraphQL engine of those systems. So how fast is their engine, how fast are they able to parse GraphQL query language, and how fast are they able to retrieve it from the underlying data sources. And so for a small GraphQL API, it's super easy. If it grows, it gets bigger, scalability really comes sneaking around the corner. So this talk we'll be talking about GraphQL servers, how to create them, and scalability. And then after this short talk of around 20 minutes, we'll start working, building some code.

So a little bit about myself. So my name is Roy, you can find me on Twitter with the handle at githackteam. If you're not on Twitter yet, it's super useful to share information with each other, especially in the tech world on Twitter. To me, at least, it taught me a lot using Twitter. There's a lot of bullshit on there, but there's also a lot of useful information. So if you don't have Twitter already, please create an account and start interacting with other tech people because it's super useful for you. I work with a company called StepZen and StepZen is the tool I'll be using today, and with this, you can create GraphQL API on top of existing data sources. You might also know me from my books, my other talks, about a year ago, I released a book, Full Stack GraphQL. So if after this talk you think StepZen is not the tool for me and you want to build a server completely, do it yourself from scratch and scale it to lots of users, then definitely ask me about the book later on today, because in there, you'll see how to build a server yourself explicitly from scratch, build all the results yourself, build the whole schema yourself, build middleware, build context, all these kinds of things, which can be quite complex. It's all explained in the book.

So if you're in this workshop, you probably also think why am I in this workshop? What I want to get out of this? Probably you want to build a GraphQL server. During this workshop, you want to know how you can take existing concepts, existing patterns and apply them your own project or maybe just interesting GraphQL, which is also perfectly fine. So there are a number of reasons to build a GraphQL server. Typically teams that start building GraphQL server have experience with other APIs such as REST or gRPC or SOAP, and they want to have a GraphQL server in order to optimize the client requests. So that's one of the most common use cases I see for GraphQL is people want to optimize the client request. So you have a client, maybe you have multiple clients, they have, they're of course sending network requests to your API, to your database, to whatever is exposing an API, and you want to optimize those requests because maybe there are lots of people using your clients, or maybe there are just lots of people sending requests, so you want to optimize these things. So GraphQL is perfectly fine for optimizing client requests. Another common use case is microservices, so imagine you maybe have 3, 4, 5, 6, maybe tens of microservices. They all have their own API, it can be REST, it can also be GraphQL, and you want to merge those things together into one data layer or API gateway. And that's something GraphQL is perfectly fine at. It's something StepZen can also do, there is a great, there's a great blog on our website about how you can do this with StepZen, how you can create a data layer or gateway for your microservices. This is something GraphQL is also useful for. And then of course you have legacy services, and this is not per se GraphQL specific, but it is something StepZen and other tools are doing very good, creating a layer around your existing legacy services so you don't have to worry about breaking things when changing things to a legacy service, because instead you'll be building a GraphQL API based on those legacy services, so you don't have to worry about changing the legacy code because you don't have to. Instead, you build a GraphQL API on top of it, which is fully performant and is helping you scale the existing legacy services, and then one by one migrate things out of there. So these are use cases. So it's either optimizing client requests, working with microservices or wrapping legacy services. So these are things GraphQL is perfectly good for. And If you want to build a GraphQL API, there are multiple ways to do so, and this is something I briefly touched in the introduction. There are multiple ways to create GraphQL servers. There are tons of libraries out there. You can build it from scratch yourself, maybe something like Prisma or Apollo or Fastify, or you can use something like StepZen in order to generate one for you based on top of your existing data services. And there are reasons to use all of these patterns. There are multiple ways to do so.

QnA

Watch more workshops on topic

Build with SvelteKit and GraphQL
GraphQL Galaxy 2021GraphQL Galaxy 2021
140 min
Build with SvelteKit and GraphQL
Top Content
Featured WorkshopFree
Scott Spence
Scott Spence
Have you ever thought about building something that doesn't require a lot of boilerplate with a tiny bundle size? In this workshop, Scott Spence will go from hello world to covering routing and using endpoints in SvelteKit. You'll set up a backend GraphQL API then use GraphQL queries with SvelteKit to display the GraphQL API data. You'll build a fast secure project that uses SvelteKit's features, then deploy it as a fully static site. This course is for the Svelte curious who haven't had extensive experience with SvelteKit and want a deeper understanding of how to use it in practical applications.

Table of contents:
- Kick-off and Svelte introduction
- Initialise frontend project
- Tour of the SvelteKit skeleton project
- Configure backend project
- Query Data with GraphQL
- Fetching data to the frontend with GraphQL
- Styling
- Svelte directives
- Routing in SvelteKit
- Endpoints in SvelteKit
- Deploying to Netlify
- Navigation
- Mutations in GraphCMS
- Sending GraphQL Mutations via SvelteKit
- Q&A
End-To-End Type Safety with React, GraphQL & Prisma
React Advanced Conference 2022React Advanced Conference 2022
95 min
End-To-End Type Safety with React, GraphQL & Prisma
Featured WorkshopFree
Sabin Adams
Sabin Adams
In this workshop, you will get a first-hand look at what end-to-end type safety is and why it is important. To accomplish this, you’ll be building a GraphQL API using modern, relevant tools which will be consumed by a React client.
Prerequisites: - Node.js installed on your machine (12.2.X / 14.X)- It is recommended (but not required) to use VS Code for the practical tasks- An IDE installed (VSCode recommended)- (Good to have)*A basic understanding of Node.js, React, and TypeScript
GraphQL for React Developers
GraphQL Galaxy 2022GraphQL Galaxy 2022
112 min
GraphQL for React Developers
Featured Workshop
Roy Derks
Roy Derks
There are many advantages to using GraphQL as a datasource for frontend development, compared to REST APIs. We developers in example need to write a lot of imperative code to retrieve data to display in our applications and handle state. With GraphQL you cannot only decrease the amount of code needed around data fetching and state-management you'll also get increased flexibility, better performance and most of all an improved developer experience. In this workshop you'll learn how GraphQL can improve your work as a frontend developer and how to handle GraphQL in your frontend React application.
Build a Headless WordPress App with Next.js and WPGraphQL
React Summit 2022React Summit 2022
173 min
Build a Headless WordPress App with Next.js and WPGraphQL
Top Content
WorkshopFree
Kellen Mace
Kellen Mace
In this workshop, you’ll learn how to build a Next.js app that uses Apollo Client to fetch data from a headless WordPress backend and use it to render the pages of your app. You’ll learn when you should consider a headless WordPress architecture, how to turn a WordPress backend into a GraphQL server, how to compose queries using the GraphiQL IDE, how to colocate GraphQL fragments with your components, and more.
Relational Database Modeling for GraphQL
GraphQL Galaxy 2020GraphQL Galaxy 2020
106 min
Relational Database Modeling for GraphQL
Top Content
WorkshopFree
Adron Hall
Adron Hall
In this workshop we'll dig deeper into data modeling. We'll start with a discussion about various database types and how they map to GraphQL. Once that groundwork is laid out, the focus will shift to specific types of databases and how to build data models that work best for GraphQL within various scenarios.
Table of contentsPart 1 - Hour 1      a. Relational Database Data Modeling      b. Comparing Relational and NoSQL Databases      c. GraphQL with the Database in mindPart 2 - Hour 2      a. Designing Relational Data Models      b. Relationship, Building MultijoinsTables      c. GraphQL & Relational Data Modeling Query Complexities
Prerequisites      a. Data modeling tool. The trainer will be using dbdiagram      b. Postgres, albeit no need to install this locally, as I'll be using a Postgres Dicker image, from Docker Hub for all examples      c. Hasura
Building GraphQL APIs on top of Ethereum with The Graph
GraphQL Galaxy 2021GraphQL Galaxy 2021
48 min
Building GraphQL APIs on top of Ethereum with The Graph
WorkshopFree
Nader Dabit
Nader Dabit
The Graph is an indexing protocol for querying networks like Ethereum, IPFS, and other blockchains. Anyone can build and publish open APIs, called subgraphs, making data easily accessible.

In this workshop you’ll learn how to build a subgraph that indexes NFT blockchain data from the Foundation smart contract. We’ll deploy the API, and learn how to perform queries to retrieve data using various types of data access patterns, implementing filters and sorting.

By the end of the workshop, you should understand how to build and deploy performant APIs to The Graph to index data from any smart contract deployed to Ethereum.

Check out more articles and videos

We constantly think of articles and videos that might spark Git people interest / skill us up or help building a stellar career

From GraphQL Zero to GraphQL Hero with RedwoodJS
GraphQL Galaxy 2021GraphQL Galaxy 2021
32 min
From GraphQL Zero to GraphQL Hero with RedwoodJS
Top Content
We all love GraphQL, but it can be daunting to get a server up and running and keep your code organized, maintainable, and testable over the long term. No more! Come watch as I go from an empty directory to a fully fledged GraphQL API in minutes flat. Plus, see how easy it is to use and create directives to clean up your code even more. You're gonna love GraphQL even more once you make things Redwood Easy!
Local State and Server Cache: Finding a Balance
Vue.js London Live 2021Vue.js London Live 2021
24 min
Local State and Server Cache: Finding a Balance
Top Content
How many times did you implement the same flow in your application: check, if data is already fetched from the server, if yes - render the data, if not - fetch this data and then render it? I think I've done it more than ten times myself and I've seen the question about this flow more than fifty times. Unfortunately, our go-to state management library, Vuex, doesn't provide any solution for this.For GraphQL-based application, there was an alternative to use Apollo client that provided tools for working with the cache. But what if you use REST? Luckily, now we have a Vue alternative to a react-query library that provides a nice solution for working with server cache. In this talk, I will explain the distinction between local application state and local server cache and do some live coding to show how to work with the latter.
Batteries Included Reimagined - The Revival of GraphQL Yoga
GraphQL Galaxy 2021GraphQL Galaxy 2021
33 min
Batteries Included Reimagined - The Revival of GraphQL Yoga
The Guild has recently released Envelop - a new, modern GraphQL Server Framework and plugin system. In this talk I’ll share a brief overview of Envelop and why you should probably upgrade your existing GraphQL server to it.
Rock Solid React and GraphQL Apps for People in a Hurry
GraphQL Galaxy 2022GraphQL Galaxy 2022
29 min
Rock Solid React and GraphQL Apps for People in a Hurry
In this talk, we'll look at some of the modern options for building a full-stack React and GraphQL app with strong conventions and how this can be of enormous benefit to you and your team. We'll focus specifically on RedwoodJS, a full stack React framework that is often called 'Ruby on Rails for React'.
Step aside resolvers: a new approach to GraphQL execution
GraphQL Galaxy 2022GraphQL Galaxy 2022
16 min
Step aside resolvers: a new approach to GraphQL execution
Though GraphQL is declarative, resolvers operate field-by-field, layer-by-layer, often resulting in unnecessary work for your business logic even when using techniques such as DataLoader. In this talk, Benjie will introduce his vision for a new general-purpose GraphQL execution strategy whose holistic approach could lead to significant efficiency and scalability gains for all GraphQL APIs.