Learning Expectations
• What is GraphQL?
• Why GraphQL is useful?
• What is Apollo?
• Resources for getting started
What Is GraphQL?
• Query language for APIs developed by Facebook
• Alternative to REST
• Client-first approach
• Not framework-specific
A Brief Caveat
• REST is Dead. ☠️
• JSONAPI is terrible
• GraphQL all the things!
What I'm not saying
Let's Talk About REST
• Provides a consistent standard for the server
• Predictable API for clients
Lets Talk About REST
• The server sets the standard
• All clients have to fall in line
In REST-land, the server is King 👑
So, What's the Problem?
Long, long ago web apps had a single server and single client.
It was a simpler time.
The multiplication of clients
So, What's the Problem?
But now we have:
• multiple web apps
• a mobile-web specific app
• a native mobile app
And all of these clients
have different needs.
The multiplication of clients
So, What's the Problem?
Making multiple requests to get a complete resource
The multiplication of clients
So, What's the Problem?
Sending excess data to clients
The multiplication of clients
So, What's the Problem?
Clients know too much about the API
The multiplication of clients
So, What's the Problem?
This created some tension in the server-client relationship.
The multiplication of clients
Enter GraphQL
Server-side
• Schema to represent data relationships
• Only one API endpoint for all requests
• Resolvers to handle various request types
In GraphQL-land, server & clients cooperate
Enter GraphQL
Client-side
• Request the specific data needed
• Request the shape of the data
In GraphQL-land, server & clients cooperate
An Example in Node
Apollo Client
View the Demo
Resources
Twitter @_alanbsmith
GitHub @alanbsmith
TinyLetter alanbsmith
GraphQL & Apollo
By Alan Smith
GraphQL & Apollo
- 848