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

Closing the Gap - For all who are tired of choosing between Apps and Websites

Closing the Gap - For all who are tired of choosing between Apps and Websites

InspiringCon 2016 talk by Wilhelm Behncke and Dmitri Pisarev

Dmitri Pisarev

April 22, 2016
Tweet

More Decks by Dmitri Pisarev

Other Decks in Programming

Transcript

  1. REST (Representational State Transfer) A set of architectural principles •

    Stateless communication • Resources - uniquely identified via URLs • Embrace HTTP to create a unified interface
  2. REST - Unified Interface GET POST PUT DELETE PATCH ...

    http://my-project.com/api/endpoint/{id}
  3. REST - HATEOAS Hypermedia as the Engine of Application State

    • Provide related URLs with every resource representation • Client navigates via those URLs
  4. REST - Challenges • Requires precise specification of resources •

    Beware of breaking changes • Many requests
  5. REST - Possible Solution in Neos Describe ad-hoc endpoints in

    TypoScript • Build endpoints that can be easily consumed by your client within one request • Use TypoScript, just like you would render an HTML document Example at: http://dimaip.github.io/2015/11/15/react-neos/
  6. GraphQL • Query Language rather than API • Queries are

    shaped just like the expected response • Let the client decide about API
  7. GraphQL - Strengths • More manageable API versioning ◦ Client

    decides about API • Less requests ◦ Queries can express exactly the dataset needed ◦ Great to map data directly to view hierarchies • Strongly typed ◦ Application specific data schema ◦ Static code analysis on queries
  8. GraphQL - Weaknesses • No HTTP Caching ◦ Everything is

    a POST request ◦ Chaching needs to be implemented individually • Not a standard ◦ So, it might change in the future…
  9. What about Content? An approach to build a query language

    based API for the Content Repository
  10. Content Repository • Certainly a very powerful way to store

    content data • Makes it easy to describe and classify content • Makes it easy to organize content in an intuitive tree structure => The perfect match for any content driven application
  11. Content Repository • Traversal over contents is a common problem

    • It is solved for TypoScript rendering via FlowQuery • FlowQuery is very expressive and intuitive to use for this task • A FlowQuery API can easily be implemented in JavaScript
  12. FlowQuery API - Challenges • Shares problems with GraphQL ◦

    No HTTP caching - everything is POST ◦ Not a standard • Number of requests need to be managed
  13. Inline Editing Problem: editors love inline editing. Solution: render editable

    field annotations in JS, from node data that we have already.
  14. Image Resources Problem: we should not allow the client to

    request images of any side, or else they would spam the cache. Solution: allow to request an image resource only of predefined sizes. But that couples server and client. Better ideas?
  15. Caching Problem: we left caching behind with TypoScript. FlowQuery has

    no caching on its own. Solutions: • Cache on the client. Cache invalidation anyone? ◦ Cache everything, flush by hand ◦ Implement real cache invalidation mechanism on the nodejs middleware, the way we do it in TS2 ◦ Something even more advanced, perhaps Event Sourcing based
  16. Summary • Rendering on the client brings crazy benefits •

    But it brings crazy challenges as well • You need to pick the right content API for the job. There is no silver bullet. • FlowQuery JS API is already around the corner. GraphQL adapter soon to follow.