GraphQL for Everyone - Danielle Man

Rate this content
Bookmark

Data is knowledge and knowledge is power. One of the greatest powers we have as developers is the ability to access and manipulate raw data with ease. But it takes a lot of context to know how to write a SQL query or use an API or make a CURL request. A lot of our energy in the GraphQL community is spent moving the specification forward and improving developer tools around it, but we don't spend much time talking about what GraphQL can do to help people in our organizations beyond our developers –– our designers, product managers, business leaders, customer success engineers, etc. In this talk, I will share the outcomes of some research we did at Apollo on GraphQL accessibility, and my vision for how GraphQL can connect humans to data that impacts them much more effectively, there giving them an ability to answer their own questions.

Danielle Man
Danielle Man
33 min
02 Jul, 2021

Comments

Sign in or register to post your comment.

Video Summary and Transcription

GraphQL can be the standard way to model and query business data, and it has the potential to go beyond just helping developers. Optimizing GraphQL queries involves mapping them to performant database queries. Translating Druid queries to GraphQL provides flexibility but has challenges with data formatting and query execution. Directives and tools like GraphQL LowDash can transform arrays of objects and provide support for applying functions to queries. Making GraphQL more accessible and integrating it into tools like Tableau can unlock its full potential.

Available in Español: GraphQL para Todos - Danielle Man

1. Introduction to GraphQL and its Potential

Short description:

I'm an engineering manager at Apollo, and today I want to talk about how to fully leverage and consume a GraphQL API. GraphQL can be useful to people in your organization beyond just the developers. It can be the standard way that we model and query our business data. We will compare SQL to GraphQL and discuss the concerns of using GraphQL as a universal access point for data.

Hey, everyone. My name is Danielle, and I'm an engineering manager at Apollo where my team and I are responsible for building dev tools specifically that help people query and use GraphQL APIs. Today, I'm really excited to be sharing some of the ideas that inspire our work centered around how you can use GraphQL to connect people in your organizations beyond just your developers to data that would empower and enable them to do their jobs more effectively.

This talk is going to be a little bit different from others because instead of talking about how to build a GraphQL API and the many interesting technical challenges there, I want to talk about how to fully leverage and consume a GraphQL API. I believe that GraphQL can be useful to people in your organization way beyond just the developers who are using it to query their data. I believe that you can build a unified graph for your data for everyone to use and that it will empower people in your organization like you've never seen before.

Data accessibility is a really hard problem, and it's really hard to access data from all of our systems these days because we store it in all sorts of different places, different databases, different microservices, everything has been optimized to be for a different type of data, everything is queried in a slightly different way, and it's hard to figure all these systems out sometimes, even as developers, but there are a lot of people who could do their jobs more effectively if they could just plug into the data in our systems. And for product development, we've solved the situation of having many services that are all a little bit different by introducing a new layer with GraphQL and using it to create a singular API. And I believe that this new layer that we've introduced for our APIs with GraphQL can also be used to solve the more general problem of data access in our organizations. I believe that GraphQL can be the standard way that we model and query our business data for almost all use cases.

So with our time today, I want to walk you all through how to think about using GraphQL in this way as we pose this question of, can GraphQL be the way that we create a universal access point for our data? And to get into this topic, I want to start by walking through a SQL query together and comparing SQL to GraphQL a little bit. So this is a query that I've written many times over myself, and it's an analytics question. For each account, how many users have I seen in the last 30 days? And if I break this query apart and look at the different elements of it, there are some distinct things that stand out. The select here lets me control what I'm asking for given a platter of options which we have the exact same ability to do with GraphQL. The where here is a conditional selection. I only want to select users if I've seen them in the last 30 days. With GraphQL, we have nothing specifically in the language to express a filter like this, but we can still filter our data using arguments. The join here lets us select data across multiple tables. With GraphQL, you actually build your join logic into your schema. So the query writer doesn't have to know anything about how to join data to benefit from being able to query join's data. I actually think that the GraphQL experience here is much better for the data browser than the SQL experience because you're not kind of reconstructing your business logic around joins. And then the last thing that I want to point out for now is this ability to group and count. This idea that we have aggregation and array functions that we can apply to our queries is something that I really miss in GraphQL. If you want to query something that's computed, you have to build those computed fields into your schema, which means you have to anticipate their needs, which you can do for applications like building layouts and clients, but you can't exhaustively anticipate every need that anyone is going to have when they're just casually browsing your data. So coming back to our question of if GraphQL can be the way to create a universal access point for our data, I think the main concerns with taking this approach are going to break down into three categories that I want to walk through together. Can I optimize my queries enough for it to make sense? GraphQL is built on top of anything. Or it could be built on top of anything. So it's going to be important to consider that we may be wanting to query very large swaths of data. Number two, can I express what I want to express? I think this one comes down to what I showed you with the SQL query where GraphQL is just kind of missing computation elements in the language itself. And then number three, can I see things the way that I want to see them? GraphQL was designed to be used by developers.

2. Optimizing GraphQL Queries

Short description:

GraphQL queries can be optimized by mapping them directly to performant database queries, which is the most efficient approach. Tools like JoinMonster help in this process. For more information, refer to the blog post by Marc-Andre Giroux.

So it's not the most accessible thing to people from the data world who are very technical but are used to working with data in table formats and doing things like Excel, applying Excel formulas and being technical in that way.

So let's walk through these together and talk about whether or not these hurdles can be overcome with GraphQL.

So this first question of can I optimize my GraphQL queries enough for it to make sense? The thing that really comes to mind with this one for me is can we provide a mapping of our queries to an implementation that is performant? GraphQL is adding this layer of processing in your stack.

So the best thing we can try to do is make that layer as thin as possible and avoid adding extra processing at the GraphQL layer. And ideally, we can take the GraphQL queries that come in and map them directly to database queries, which is guaranteed to be the most performant outcome.

And there are a lot of tools that do this or that help you do this specifically with SQL that are out there. There are even companies that build a GraphQL on top of SQL as a service. And in all of those tools, what you're trying to do is take your GraphQL query and identify the precise SQL query that needs to be made to fetch the data that was asked for.

And what I have on this slide is an example of one of those libraries called JoinMonster that does this. But there's a great blog post written on the topic of GraphQL to SQL, specifically that I've linked here in this slide by Marc-Andre Giroux.

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.
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.

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.