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

This workshop has been presented at GraphQL Galaxy 2021, check out the latest edition of this Tech Conference.

FAQ

Stepsen is a tool that allows users to create a GraphQL API on top of existing data sources such as MySQL, Postgres, REST APIs, or other GraphQL APIs. It simplifies the process by enabling the serverless deployment of APIs, where the GraphQL schema is defined and Stepsen handles the creation of resolvers and server management automatically.

Yes, Docker is required if you want to work with MySQL or Postgres databases during the workshop, as it is used to run these databases locally on your machine. If you are not using these databases, you can use a provided REST API instead.

Ngrok is a tool that creates a secure tunnel to your local machine. It is necessary for the workshop to expose your locally running database (set up through Docker) to the internet, allowing Stepsen to access it for creating a serverless GraphQL API.

Yes, you can participate in the workshop without previous experience in GraphQL. The workshop is designed to accommodate beginners, and the presenter is prepared to adjust the explanations based on participants' familiarity with GraphQL.

If you prefer to use your own REST API during the workshop, you should ensure it is publicly accessible. During the workshop, you will be guided on how to connect your REST API with Stepsen to create a serverless GraphQL API.

Stepsen integrates data from various sources like SQL databases, REST, and existing GraphQL APIs by using custom directives in the schema definition. These directives specify the source of data for each field, allowing Stepsen to fetch and integrate data efficiently into a unified GraphQL schema.

The workshop discusses that while building an initial GraphQL API is straightforward, scaling it can be challenging without deep knowledge of GraphQL and the underlying systems. It emphasizes understanding how data is related and managed in the API to effectively scale and maintain performance.

You can continue experimenting with GraphQL and Stepsen by accessing the GraphQL Studio on the Stepsen website, which allows for easy exploration and creation of APIs with different combinations of data sources. Additionally, engaging with the Stepsen community through their Discord channel is encouraged for further learning and support.

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.

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
Build Modern Applications Using GraphQL and Javascript
Node Congress 2024Node Congress 2024
152 min
Build Modern Applications Using GraphQL and Javascript
Featured Workshop
Emanuel Scirlet
Miguel Henriques
2 authors
Come and learn how you can supercharge your modern and secure applications using GraphQL and Javascript. In this workshop we will build a GraphQL API and we will demonstrate the benefits of the query language for APIs and what use cases that are fit for it. Basic Javascript knowledge required.
End-To-End Type Safety with React, GraphQL & Prisma
React Advanced 2022React Advanced 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

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
Tom Pressenwurter introduces Redwood.js, a full stack app framework for building GraphQL APIs easily and maintainably. He demonstrates a Redwood.js application with a React-based front end and a Node.js API. Redwood.js offers a simplified folder structure and schema for organizing the application. It provides easy data manipulation and CRUD operations through GraphQL functions. Redwood.js allows for easy implementation of new queries and directives, including authentication and limiting access to data. It is a stable and production-ready framework that integrates well with other front-end technologies.
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
This Talk discusses handling local state in software development, particularly when dealing with asynchronous behavior and API requests. It explores the challenges of managing global state and the need for actions when handling server data. The Talk also highlights the issue of fetching data not in Vuex and the challenges of keeping data up-to-date in Vuex. It mentions alternative tools like Apollo Client and React Query for handling local state. The Talk concludes with a discussion on GitLab going public and the celebration that followed.
Batteries Included Reimagined - The Revival of GraphQL Yoga
GraphQL Galaxy 2021GraphQL Galaxy 2021
33 min
Batteries Included Reimagined - The Revival of GraphQL Yoga
Envelope is a powerful GraphQL plugin system that simplifies server development and allows for powerful plugin integration. It provides conformity for large corporations with multiple GraphQL servers and can be used with various frameworks. Envelope acts as the Babel of GraphQL, allowing the use of non-spec features. The Guild offers GraphQL Hive, a service similar to Apollo Studio, and encourages collaboration with other frameworks and languages.
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
The Talk discusses the challenges and advancements in using GraphQL and React together. It introduces RedwoodJS, a framework that simplifies frontend-backend integration and provides features like code generation, scaffolding, and authentication. The Talk demonstrates how to set up a Redwood project, generate layouts and models, and perform CRUD operations. Redwood automates many GraphQL parts and provides an easy way for developers to get started with GraphQL. It also highlights the benefits of Redwood and suggests checking out RedwoodJS.com for more information.
Adopting GraphQL in an Enterprise
GraphQL Galaxy 2021GraphQL Galaxy 2021
32 min
Adopting GraphQL in an Enterprise
Today's Talk is about adopting GraphQL in an enterprise. It discusses the challenges of using REST APIs and the benefits of GraphQL. The Talk explores different approaches to adopting GraphQL, including coexistence with REST APIs. It emphasizes the power of GraphQL and provides tips for successful adoption. Overall, the Talk highlights the advantages of GraphQL in terms of efficiency, collaboration, and control over APIs.
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
GraphQL has made a huge impact in the way we build client applications, websites, and mobile apps. Despite the dominance of resolvers, the GraphQL specification does not mandate their use. Introducing Graphast, a new project that compiles GraphQL operations into execution and output plans, providing advanced optimizations. In GraphFast, instead of resolvers, we have plan resolvers that deal with future data. Graphfast plan resolvers are short and efficient, supporting all features of modern GraphQL.