on their website
query {
users {
name
}
likes {
id
}
}
Sample Call
curl 'http://localhost/graphql?' \
-XPOST \
--data-binary
'query { users: { name } likes: { id } }'
users {
name : String
likes {
id: Int
}
}
likes {
id: Int
}
Sample Schema
query {
users {
name
likes: {
id
}
}
}
Sample Call
Who Wants What
Users
Faster Products
Developer
More Free Time
Sales
More Customers
Support
No Hard User Issues
Faster Products
More Customers
More Free Time
No Hard User Issues
Technical Writers
Lesser Documenting
Lesser Documenting
Just Make Another Call
GET /users
GET /likes/1
GET /likes/2
GET /likes/3
No of Calls: 4
REST
3
Prathik
4
Saurabh
5
Armaan
When user list and likes are separate calls
System will Collapse
query {
users {
name
profilepic
bio
likes: {
id
}
}
}
No of Calls: 1
GraphQL
3
Prathik
4
Saurabh
5
Armaan
Just Rename That Field
[{
name
profilepic
bio
}]
[{
name
pic
bio
}]
Things Change Everywhere
REST
When API renames a field
query {
users: {
name
profilepic: pic
bio
}
}
No Code Change
GraphQL
Just Play Around
REST
REST
GraphQL
GraphQL
I Don't Need That
REST
GET /users
GET /users-without-pic
or
GET /users?includepic=false
Prathik
3
Saurabh
4
Armaan
33
Loki
300
3
Prathik
4
Saurabh
When you want to skip a field
query {
users: {
name
bio
pic
likes: {
id
}
}
}
GraphQL
query {
users: {
name
likes: {
id
}
}
}
Prathik
3
Saurabh
4
Armaan
33
Loki
300
3
Prathik
4
Saurabh
Thank You