What is GraphQL?
A specification, query Language for your API. Find the GraphQL Spec here.
How is GraphQL better than REST (for some specific scenarios)?
REST API may require the web client to call multiple REST endpoints (APIs) to retrieve the full response you need and then do heavy operations on the client side such as sorting, parsing, filtering to stitch the data together.
With GraphQL, a web client calls a single GraphQL endpoint and GraphQL moves a lot of the sorting, parsing, filtering, transformation logic to the web server leaving the client to simply render the response… making it extremely fast, low latency for applications such as mobile, VR etc. Ex - Facebook’s live likes / emojis on live videos are powered by GraphQL subscriptions.
(fn → GraphQL resolver functions)
Where can I practice GraphQL?
Start with a GraphQL playground ex- https://snowtooth.moonhighway.com/
How does REST operations map to GraphQL?
GET → Query
POST / PUT / DELETE → Mutation
Webhooks → Subscriptions (listens for real time changes over web sockets)
What are some quick GraphQL examples?
Copy paste below examples in the Playground: https://snowtooth.moonhighway.com/
query {
liftCount
allLifts {
name
}
}
mutation {
setLiftStatus(id: "jazz-cat", status: OPEN) {
name
status
}
}