Slide 1

Slide 1 text

Pixelpillow College Tour HTTP APIs

Slide 2

Slide 2 text

Waaaa tt t?!?! • HTTP als protocol. • Een communica ti elaag tussen twee system.

Slide 3

Slide 3 text

HTTP is een… • URL – h tt ps://google.com/search?q=lmgt fy • Methode – POST, PATH, DELETE • Headers – Content-Type: “applica ti on/json” • Body – { “foo”: “bar” } • Status code – 200 OK

Slide 4

Slide 4 text

Maar zegt niks over… • Structuur (zoals paden) • Transport (HTML, XML, JSON, etc.)

Slide 5

Slide 5 text

Dus: smaakjes! • SOAP • RESTful • JSON-API • GraphQL

Slide 6

Slide 6 text

SOAP

Slide 7

Slide 7 text

SOAP

Slide 8

Slide 8 text

RESTful Stateless – Geen afhankelijkheden tussen opvolgende requests. Decoupled – Geen aannames over gebruik door een client. Cacheable – En dus snel Uniform – Voorspelbaar!

Slide 9

Slide 9 text

RESTful requests GET /api/posts ! 200 OK POST /api/posts ! 201 Created GET /api/posts/1 ! 200 OK PATCH /api/posts/12 ! 200 OK DELETE /api/posts/12 ! 410 Gone

Slide 10

Slide 10 text

RESTful is niet genoeg… Geen standaard, slechts principes 👎 Geen ondersteuning voor “ac ti es” 🤔 Rela ti onele data is las ti g. 😭

Slide 11

Slide 11 text

JSON-API: Best of REST Een standaard! Vanuit de prak ti jk ( fi lters, meta data, etc.) Rela ti es via links en included

Slide 12

Slide 12 text

{ "data": [ { "type": "articles", "id": "1", "attributes": { “title": "JSON:API paints my bikeshed!" }, "relationships": { "author": { "links": { "self": "http://example.com/articles/1/relationships/author", "related": "http://example.com/articles/1/author" }, "data": { "type": "people", "id": "9" } }, "comments": { "links": { "self": "http://example.com/articles/1/relationships/comments", "related": "http://example.com/articles/1/comments" }, "data": [ { "type": "comments", "id": "5" }, { "type": "comments", "id": "12" } ] } }, "links": { "self": "http://example.com/articles/1" } }], "included": [{ "type": "people", "id": "9", "attributes": { "firstName": "Dan", "lastName": "Gebhardt", "twitter": "dgeb" },

Slide 13

Slide 13 text

{ "data": [ { "type": "articles", "id": "1", "attributes": { "title": "JSON:API paints my bikeshed!" }, "relationships": { "author": { "links": { "self": "http://example.com/articles/1/relationships/author", "related": "http://example.com/articles/1/author" }, "data": { "type": "people", "id": "9" } }, "comments": { "links": { "self": "http://example.com/articles/1/relationships/comments", "related": "http://example.com/articles/1/comments" }, "data": [ { "type": "comments", "id": "5" }, { "type": "comments", "id": "12" } ] } }, "links": { "self": "http://example.com/articles/1" } }], "included": [{ "type": "people", "id": "9", "attributes": { "firstName": "Dan", "lastName": "Gebhardt", "twitter": "dgeb" },

Slide 14

Slide 14 text

JSON:API hee ft geen… Geen ondersteuning voor “ac ti es” 🤔 (bijv. het favoriten van een resource) Is niet self-documen ti ng… 📚

Slide 15

Slide 15 text

GraphQL Alles is een graaf™ Mutations en Queries

Slide 16

Slide 16 text

GraphQL Playground!!! https://www.apollographql.com/docs/apollo-server/v2/testing/graphql-playground/

Slide 17

Slide 17 text

Can’t have your cake and eat it too. Paradigma sluit niet aan bij onze manier van backends bouwen.

Slide 18

Slide 18 text

Vragen? 038 750 3491 [email protected]