Upgrade to Pro — share decks privately, control downloads, hide ads and more …

GraphQL vs. JSON:API

Aimeos
September 04, 2020

GraphQL vs. JSON:API

Compares how GraphQL and the JSON REST API standard fits for e-commerce and CMS applications

Aimeos

September 04, 2020
Tweet

More Decks by Aimeos

Other Decks in Programming

Transcript

  1. {"data": { "product": { "name": "Simple product", "media": [{ "url":

    "http://localhost/img/simple1.jpg" },{ "url": "http://localhost/img/simple2.jpg" }] } }} Response
  2. curl -X POST -H 'Content-Type: application/json' -d '{ "query": "{

    products { name } }" }' http://localhost/graphql Query
  3. {"data": [{ "id": 1, "type": "product", "attributes": { "uid": "1",

    "code": "SP01", "name": "Simple product", } }]} Response
  4. {"data": [{ "id": 1, "type": "product", "attributes": { … }

    "relationships": { "price": [{"id": "123"}] }}], "included": [{ "id": 123, "type": "price", "attributes": { … } }]} Response
  5. Hypermedia As The Engine Of Application State "links": { "self":

    "http://localhost/jsonapi/product/13", "next": "http://localhost/jsonapi/product/21", "basket/product": "http://localhost/jsonapi/basket/default/product" } HATEOAS