15. Amazon AppSync, GraphQL as a Service
GraphQL ? 🤔
• Apollo
(AppSync Apollo )
• Facebook
• A query language for your API
16. Amazon AppSync, GraphQL as a Service
GraphQL - Schema (Definition, Query)
type Project {
id: Number
name: String
tagline: String
}
type query {
getProject(name: String): Project
}
17. Amazon AppSync, GraphQL as a Service
GraphQL - Query
query {
getProject(name: “GraphQL”) {
tagline
}
}
18. Amazon AppSync, GraphQL as a Service
GraphQL - Result
{
“getProject”: {
“tagline”: “A query language for APIs”
}
}
19. Amazon AppSync, GraphQL as a Service
GraphQL - Schema (Mutation)
...
type mutation {
createProject(name: String, tagline: String): Project
}
20. Amazon AppSync, GraphQL as a Service
GraphQL - Mutate
mutation {
createProject(
name: “AppSync”,
tagline: “GraphQL as a Service”
){
id
tagline
}
}
21. Amazon AppSync, GraphQL as a Service
GraphQL - Result
{
“createProject”: {
“id”: “EQ9S0-2039DKAP-1201S”,
“tagline”: “GraphQL as a Service”
}
}
23. Amazon AppSync, GraphQL as a Service
GraphQL - Resolver (Schema)
type Query {
getProject(name: String): Project
}
type Project {
id: Number
name: String
tagline: String
contributors: [User]
}
type User {
id: String
firstName: String
lastName: String
following: [User]
}
24. Amazon AppSync, GraphQL as a Service
GraphQL - Resolver (Sample Query)
query {
getProject(name: “GraphQL”) {
tagline
contributors {
firstName
lastName
following {
lastName
}
}
}
}
25. Amazon AppSync, GraphQL as a Service
GraphQL - Resolver
query {
getProject(name: “GraphQL”) {
tagline
contributors {
firstName
lastName
following {
lastName
}
}
}
}
getProject
DB
Project
Resolver
26. Amazon AppSync, GraphQL as a Service
GraphQL - Resolver
query {
getProject(name: “GraphQL”) {
tagline
contributors {
firstName
lastName
following {
lastName
}
}
}
}
tagline
getProject
Resolver return
contributors
27. Amazon AppSync, GraphQL as a Service
GraphQL - Resolver
query {
getProject(name: “GraphQL”) {
tagline
contributors {
firstName
lastName
following {
lastName
}
}
}
}
firstName
contributors
Resolver return
lastName
following
28. Amazon AppSync, GraphQL as a Service
GraphQL - Resolver
query {
getProject(name: “GraphQL”) {
tagline
contributors {
firstName
lastName
following {
lastName
}
}
}
}
follows
Resolver return
lastName
29. Amazon AppSync, GraphQL as a Service
GraphQL - Resolver
getProject contributors
tagline
following
lastName
firstName
lastName
30. Amazon AppSync, GraphQL as a Service
GraphQL - Resolver
ontributors
following
lastName
firstName
lastName
• Type Resolver
• Resolver Resolver
• Resolver
• ‘Graph!’