The Diminishing API Layer

Rate this content
Bookmark

Apps are hard enough to build without having to worry about layers and layers that sit between your users and the database. In this talk we examine trends in serverless computing, and their impact on modern databases and API layers.

Tejas Dinkar
Tejas Dinkar
30 min
02 Jul, 2021

Comments

Sign in or register to post your comment.

Video Summary and Transcription

The Talk discusses the evolution of code and data coupling, the challenges of managing code and API complexity, and the rise of GraphQL as a solution. It explores the power of directives in GraphQL and their ability to preprocess and post-process requests and responses. The at lambda directive is highlighted as a way to implement fields in JavaScript. The Talk also touches on the benefits of working from home and the flexibility of placing directives in various parts of a GraphQL schema.

Available in Español: La Capa API en Disminución

1. Introduction

Short description:

Hi, everyone. My name is Tejas and I work on slash GraphQL at dGraph Labs. Today, I want to talk about the diminishing API layer and how we as a community move all that logic out of databases and then one day suddenly decided to move it all back in. 2020 has been a difficult year for everybody, but one good thing that's happened to me is my partner and I have just had a baby girl. As I read The Very Hungry Caterpillar, it gave me a lot of free time to think about philosophical questions about data and its relationship to logic and code.

Hi, everyone. My name is Tejas and I work on slash GraphQL at dGraph Labs. You can find me on Twitter at At T. Dinker.

Today, I want to talk about a little bit about something that's been interesting to me for a while and I'm calling this talk the diminishing API layer. However, I also had an alternate title for this talk and that was there and back again, or how we as a community move all that logic out of databases. And then one day suddenly decided to move it all back in.

So 2020 has been a pretty difficult year for everybody. It's been a global pandemic and things have been very hard. But one thing that's good that's happened to me is my partner and I have just had a baby girl. And so as I read The Very Hungry Caterpillar for probably the 4000th time this year, it gave me a lot of free time to get inside my head and think a lot about philosophical questions that really may not have any actual practical implications. And one thing I've been thinking a lot about these days is what is data? What actually do we mean when we talk about data and how is it different from logic or actual code?

2. Code and Data Coupling

Short description:

Clojure has the concept of Homo-iconicity, allowing code to be expressed as data. Domain-specific languages have also blurred the line between data and code. This raises the question of whether code should be stored in databases. Early examples of tight coupling between code and data, like Oracle Forms, led to difficulties in testing, deploying, and managing systems. This led to the era of boilerplate, where APIs were decoupled from databases. Unit tests would mock databases, and code would be developed against interfaces like iRepository.

And Clojure has this concept of Homo-iconicity, right? And Homo-iconicity is the property of a programming language to be able to express your code as data, right? So in Clojure, you can actually write a macro, which basically accepts actual code, and you can process it with the same sort of data structures that you would process your regular data with. And even outside of programming languages like Clojure, domain-specific languages have become very popular over the last, I don't know, 10 or 15 years.

And domain-specific languages are simply purpose-built languages where you have various rules which are code, sort of written in some format, and then they're interpreted by whoever's parsing that domain-specific language. So once again, we see over here as well, you really have this distinction between data and code blurring significantly. So this sort of leads me to the next question, that is, if code is data, then is there a difference between your code data versus your data data? And if not, should your code actually be in your database?

So the first time I ever sort of came across something like this, where you're very closely coupling your code and your data, was this where sort of something I worked on very early in my career in the late 2000s. And my first experience with something like this was with Oracle Forms. So Oracle Forms is a great example of a very tight coupling between data and your code. And it's not so popular today for various reasons. But back then, Oracle would give you the database. It would give you the language that you would build these tools with. Your inputs would typically be drag-and-drop pages that you've built. And then you operate on them with PLSQL, and you shove it into your database, and then you finally query it out with views and SQL.

So in essence, your code and your data was together one single unit that would be deployed to various places. And it's not that Oracle Forms was the only one who was doing this by any means. There's many of these other things, like for example, FoxPro, for example, comes to mind. And even the systems that had a separate code layer, you would still very often rely on very database-specific features, like triggers and procedures. And this did work. You would have very large systems that are built out with these tools. And they were reasonably easy when you were first building them. But people realized pretty quickly that this was very tough to test. It was hard to deploy, because you'd often be just rewriting a stored procedure in your database. And it was tough to manage. It was impossible to version. There was just so many stuff that needed to happen. And I feel this sort of tight coupling led to everyone going in the exact opposite direction for a long time. And we sort of entered what I'm calling the era of boilerplate. Right?

So in the era of boilerplate, you'd have a bunch of APIs, and just without calling out any specific language, you know, maybe that would be like a Data Bean factory factory implementation. And these APIs would be very decoupled from your actual database. In fact, you would go so far as to be very proud of the fact that unit tests would have your database and stuff mocked. Instead of writing against an actual database, your code would be developed and deployed against the iRepository fit interface, which, you know, you expect the repository to be sort of implemented.

QnA

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.
Get rid of your API schemas with tRPC
React Day Berlin 2022React Day Berlin 2022
29 min
Get rid of your API schemas with tRPC
Do you know we can replace API schemas with a lightweight and type-safe library? With tRPC you can easily replace GraphQL or REST with inferred shapes without schemas or code generation. In this talk we will understand the benefit of tRPC and how apply it in a NextJs application. If you want reduce your project complexity you can't miss this talk.
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'.

Workshops on related 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.