URI - These resources are manipulated using HTTP requests where the method (GET, POST, PUT, PATCH, DELETE) has specific meaning. - Discover resources, thanks to HATEOAS (Hypertext As The Engine Of Application State). 10
of tickets GET /posts/12 - Retrieves a specific ticket GET /posts/12/comments - Retrieves comments GET /posts/12/comments/42/ - Retrieve specific comment POST /posts - Creates a new post PUT /posts/12 - Updates post #12 with payload provided PATCH /posts/12 - Partially updates post #12 DELETE /posts/12 - Deletes post #12 11
Ad-hoc RPC with custom endpoint definitions. Time spent maintaining many versioned endpoint - REST requires many requests - With REST, you request too much or too little data - REST often turns into a maze of poorly-documented endpoints 18
by providing an intuitive and flexible syntax and system for describing their data requirements and interactions.” - GraphQL Specification https://facebook.github.io/graphql/ 22
GraphQL directly to your backend or database. It’s an API layer, just like REST. GraphQL can be layered over multiple backends and databases, without the client being aware of where the data is coming from, just like REST. 23
are the way to allow GraphQL clients(or external parties) to modify your dataset. mutation writePost { post: createPost( title: "GraphQL is Awesome", content: "Yep, it's purely awesome." ) { _id, title } } 33
(size: 250){ url } coverPhoto (size: 1200){ name, url } } fragment bodyFragment on User { location { name } friends } 42 fragment timelineFragment on User { ...headerFragment ...bodyFragment }
a function called the resolver which is provided by the GraphQL server developer When a field is executed, the corresponding resolver is called to produce the next value. 53
opponents and making them see the light, but rather because its opponents eventually die out, and a new generation grows up that is familiar with it. — Max Planck Are RESTful APIs dead? 66