Introduction to decoupled Drupal Preston So 26 Sep 2017 - - PowerPoint PPT Presentation

introduction to decoupled drupal
SMART_READER_LITE
LIVE PREVIEW

Introduction to decoupled Drupal Preston So 26 Sep 2017 - - PowerPoint PPT Presentation

Introduction to decoupled Drupal Preston So 26 Sep 2017 DrupalCon Vienna 2017 Herzlich Willkommen! Preston So has been a web developer and designer since 2001, a creative professional since 2004, and a Drupal developer since


slide-1
SLIDE 1

Introduction to decoupled Drupal

Preston So • 26 Sep 2017 • DrupalCon Vienna 2017

slide-2
SLIDE 2

Herzlich Willkommen!

Preston So has been a web developer and designer since 2001, a creative professional since 2004, and a Drupal developer since 2007. As Director of Research and Innovation at Acquia, Preston leads new

  • pen-source and research initiatives and helms Acquia Labs, the

innovation lab featured in international press. Previously, Preston contributed to the Spark initiative in the Drupal project, co-founded the Southern Colorado Drupal User Group (est. 2008), and operated an award-winning freelance web and print design studio. Preston has presented keynotes at conferences on three continents in multiple languages. preston.so@acquia.com • @prestonso • #introdecoupleddrupal

slide-3
SLIDE 3

What we'll cover

  • What is decoupled Drupal?
  • Motivating decoupled Drupal
  • Decoupling the front end from the back end
  • Risks and rewards of decoupling Drupal
  • Web services and REST APIs
  • Decoupled Drupal and developer experience
  • Decoupled Drupal and editorial experience
  • Epilogue: Drupal's new incongruity
slide-4
SLIDE 4

What is decoupled Drupal?

1

slide-5
SLIDE 5
slide-6
SLIDE 6

Think of Earth as one contiguous unit: a monolith.

slide-7
SLIDE 7
slide-8
SLIDE 8

Earth responds to requests from decoupled bases.

request response

slide-9
SLIDE 9

Drupal is a monolithic CMS backing decoupled applications.

HTTP request HTTP response

slide-10
SLIDE 10

HTTP request HTTP response

Site or repository built in Drupal Decoupled application

slide-11
SLIDE 11

Site or repository built in Drupal Decoupled application

REST API Decoupled application HTTP client

HTTP request HTTP response

slide-12
SLIDE 12

Decoupled Drupal is the use of Drupal as a content service for consumption and manipulation by other applications

slide-13
SLIDE 13

Decoupled Drupal

  • Drupal can be used to back other back-end

applications as well as native applications, single-page applications, digital signage, AR-driven interfaces, and many others.

  • Web services such as the core REST API, JSON API,

and GraphQL are typical entry points for Drupal consumers.

slide-14
SLIDE 14

Monolithic vs. decoupled Drupal

Drupal Drupal front end

PHP Data Templates HTML

Drupal Decoupled application

PHP Data Templates HTML Other language JSON

REST API

slide-15
SLIDE 15

Drupal Native Android application

PHP Data Templates App code Java JSON

REST API Drupal Single-page application (universal JavaScript)

PHP Data Templates HTML JavaScript JSON

REST API

slide-16
SLIDE 16

Silex application

Data Templates HTML or app code PHP JSON

Drupal Native iOS application

PHP Swift

REST API

slide-17
SLIDE 17

de•coup•led head•less API•first

Aside: What's in a name?

slide-18
SLIDE 18

Motivating decoupled Drupal

2

slide-19
SLIDE 19

For marketers and publishers decoupled Drupal offers the promise

  • f omnichannel delivery
slide-20
SLIDE 20

IoT apps Native apps Chat apps Single- page apps Other back ends Set-top boxes Smart watches Fitness devices Arduino boards Beacons AR/VR apps Rasp- berry Pi Conver- sational UIs LED displays

We have new channels every day.

slide-21
SLIDE 21

IoT apps Native apps Chat apps Single- page apps Other back ends Set-top boxes Smart watches Fitness devices Arduino boards Beacons AR/VR apps Rasp- berry Pi Conver- sational UIs LED displays

And ones we've never heard of yet.

? ? ? ? ?

slide-22
SLIDE 22

For developers decoupled Drupal offers the promise

  • f front-end freedom
slide-23
SLIDE 23

Decoupling the front end from the back end

3

slide-24
SLIDE 24

Monolithic Drupal

Drupal Drupal front end

Client Server Client Server

slide-25
SLIDE 25

Static pages

Drupal Drupal front end

Client Server

Subscribe to our newsletter You have been successfully subscribed! E-mail address Submit

full-page refresh two bootstraps

slide-26
SLIDE 26

Dynamic pages with Ajax

Client Server

Drupal Drupal front end jQuery

Synchronous Asynchronous Ajax request

Subscribe to our newsletter E-mail address Submit Subscribe to our newsletter E-mail address Submit Subscribe to our newsletter E-mail address Submit Success!

  • ne

bootstrap

slide-27
SLIDE 27

Drupal JavaScript application framework Initial markup

Client-side JavaScript

Drupal Drupal front end jQuery Drupal

Client Server Client Server

slide-28
SLIDE 28

Success! Here are

  • thers that

might interest you: Lorem ipsum dolor sit amet, consectetuer adipiscing. Subscribe to our newsletter E-mail address Submit Lorem ipsum dolor sit amet, consectetuer adipiscing. Subscribe E-mail Submit Lorem ipsum dolor sit amet, consectetuer adipiscing. Drupal

Dynamic pages with client-side rendering

Client Server Synchronous Asynchronous

  • ne

bootstrap

JavaScript application framework

HTTP request

Initial markup

slide-29
SLIDE 29

Success! Here are

  • thers that

might interest you: Lorem ipsum dolor sit amet, consectetuer adipiscing. Subscribe to our newsletter E-mail address Submit Lorem ipsum dolor sit amet, consectetuer adipiscing. Subscribe E-mail Submit Lorem ipsum dolor sit amet, consectetuer adipiscing. Drupal

Dynamic pages with client-side rendering

Client Server Synchronous Asynchronous

  • ne

bootstrap

JavaScript application framework

HTTP request

Initial markup

slide-30
SLIDE 30

The JavaScript renaissance ushered in an era of innovation and new development practices

slide-31
SLIDE 31

Server-side JavaScript meant client-side frameworks could be executed server-side

slide-32
SLIDE 32

Universal JavaScript meant shared code in the form of JavaScript framework executions

slide-33
SLIDE 33

Drupal JavaScript application framework Initial markup

Server-side JavaScript

Client Server Client Server

JavaScript framework (client-side execution) Node.js JavaScript framework (server-side execution) Drupal

slide-34
SLIDE 34

JavaScript framework (client-side execution) Node.js JavaScript framework (server-side execution) Drupal Success! Here are

  • thers that

might interest you: Lorem ipsum dolor sit amet, consectetuer adipiscing. Subscribe to our newsletter E-mail address Submit Lorem ipsum dolor sit amet, consectetuer adipiscing. Subscribe E-mail Submit Lorem ipsum dolor sit amet, consectetuer adipiscing.

Dynamic pages with server-side prerendering

Client Server Synchronous Asynchronous HTTP request HTTP request

slide-35
SLIDE 35

Universal (isomorphic) JavaScript

Server Client

Node.js JavaScript framework HTML JavaScript framework HTML

Synchronous Asynchronous executes renders flush bindings by responds calls REST API

slide-36
SLIDE 36

Universal JavaScript consuming Drupal

Server Client

Node.js JavaScript framework HTML JavaScript framework HTML

Synchronous Asynchronous executes renders flush bindings by responds calls REST API

Drupal

calls REST API responds

slide-37
SLIDE 37

JavaScript framework (client-side execution) Node.js JavaScript framework (server-side execution) Drupal Success! Here are

  • thers that

might interest you: Lorem ipsum dolor sit amet, consectetuer adipiscing. Subscribe to our newsletter E-mail address Submit Lorem ipsum dolor sit amet, consectetuer adipiscing. Subscribe E-mail Submit Lorem ipsum dolor sit amet, consectetuer adipiscing.

Fully decoupled Drupal

Client Server Synchronous Asynchronous HTTP request HTTP request

slide-38
SLIDE 38

Success! Here are

  • thers that

might interest you: Lorem ipsum dolor sit amet, consectetuer adipiscing. Subscribe to our newsletter E-mail address Submit Lorem ipsum dolor sit amet, consectetuer adipiscing. Subscribe E-mail Submit Lorem ipsum dolor sit amet, consectetuer adipiscing. Drupal

Progressively decoupled Drupal

Client Server Synchronous Asynchronous

  • ne

bootstrap

Drupal front end JavaScript framework

HTTP request

slide-39
SLIDE 39

Risks and rewards of decoupled Drupal

4

slide-40
SLIDE 40

Rewards of decoupled Drupal

  • Separation of concerns. Structure versus

presentation is increasingly relevant in decoupled architectures.

  • Pipelined development. An API-design-first

approach gives front-end and back-end teams independence.

slide-41
SLIDE 41

Rewards of decoupled Drupal

  • Administrative security. Keeping the

administrative CMS far from public view is increasingly a best practice.

  • Easier resourcing. Drupal developers are now

considered less affordable than JavaScript developers.

slide-42
SLIDE 42

Risks of decoupled Drupal

  • Loss of contextual administration. Crucial

features such as in-place editing and toolbar can be key for editors.

  • Maintainability difficulties. Maintaining both

Drupal service and consumers requires extensive planning.

slide-43
SLIDE 43

Risks of decoupled Drupal

  • Additional point of failure. Node.js downtime can

lead to inaccessible content in the case of private Drupal.

  • On-boarding overhead. JavaScript developers

need to learn consumption; Drupal developers change focus.

slide-44
SLIDE 44

Summary

Area Rewards Risks Architecture Separation of concerns Loss of contextual administration Development experience Pipelined development Maintainability difficulties Security and performance Administrative security Additional point of failure Project management Easier resourcing On-boarding overhead

slide-45
SLIDE 45

Web services and REST APIs

5

slide-46
SLIDE 46

Site or repository built in Drupal Decoupled application

REST API Decoupled application HTTP client

HTTP request HTTP response

slide-47
SLIDE 47

Web services Decoupled application HTTP client

HTTP request HTTP response

Not all web services are REST APIs

slide-48
SLIDE 48

Web services support interoperable machine-to-machine interaction over a network

slide-49
SLIDE 49

REST APIs follow REST principles and operate using HTTP methods

slide-50
SLIDE 50

Drupal core (with HAL normalization) Depends on Serialization Depends on REST and Serialization Drupal core (raw JSON structures, no HAL) REST Serialization HAL JSON API Waterwheel RELAXed Web Services GraphQL depends on

Drupal's web services ecosystem (not exhaustive)

slide-51
SLIDE 51

Core REST JSON API RELAXed Web Services GraphQL

Core and contrib web services modules

slide-52
SLIDE 52

REST APIs Web services REST APIs Core REST JSON API RELAXed Web Services GraphQL

Euler diagram of Drupal web services

slide-53
SLIDE 53

Core REST

The core REST modules allow for all content entities (nodes, users, taxonomy terms, comments) to be exposed as JSON+HAL or as JSON representing Drupal’s internal storage, and Views natively supports “REST export” as a new display type.

slide-54
SLIDE 54

Core REST

Current core REST (abbreviated payloads) Client issues request for an entity resource Server issues response with single entity resource

GET /node/1?_format=json "field_author": [ { "value": "5" } ] GET /user/5?_format=json "name": [ { "value": "Joe" } ]

slide-55
SLIDE 55

JSON API

  • JSON API is a specification for REST APIs in JSON

popular among JavaScript developers and adopted by the Ember and Rails communities.

  • JSON API provides a standard way to query single

entities, but it also provides all relationships contained therein and query operations via query string parameters.

slide-56
SLIDE 56

JSON API

  • JSON API allows you to fetch lists of content

entities (filter, sort, pagination) — which is currently only possible via multiple requests or Views REST exports.

  • drupal.org/project/jsonapi
slide-57
SLIDE 57

JSON API

JSON API (abbreviated payloads, merely illustrative) Client issues request for an entity resource Server issues response with single entity and all relationships

GET /jsonapi/node/1 ?include=field_author { "data": [{ "type": "articles", "id": "1", "attributes": { "title": "Foo", "body": "Lorem ipsum", }, ... }], "included": [{ "type": "people", "id": "5", "attributes": { "name": "Joe" } }] }

slide-58
SLIDE 58

GraphQL

  • GraphQL, originally created by Facebook to power

its data fetching, is a query language that enables fewer queries and limits response bloat.

  • Rather than tightly coupling responses with a

predefined schema, GraphQL overturns this common practice by allowing for the client's request to explicitly tailor a response so that the client only receives what it needs.

slide-59
SLIDE 59

GraphQL

  • GraphQL shifts responsibility from the server to

the client: the server publishes its possibilities, and the client publishes its requirements instead of receiving a response dictated solely by the server.

  • drupal.org/project/graphql
slide-60
SLIDE 60

GraphQL

GraphQL (simplified payloads, merely illustrative) Client issues request declaring data requirements Server issues response matching structure of declared requirements

{ title fieldAuthor { title } } { "title": "Foo" "fieldAuthor": { "title": "Joe" } }

slide-61
SLIDE 61

RELAXed Web Services

  • RELAXed Web Services includes support for

translations, parent revisions (via Multiversion), file attachments, and cross-environment UUID references.

  • It uses the CouchDB API specification, which

means that CouchDB integration with client-side libraries such as PouchDB and Hood.ie makes possible offline-enabled Drupal.

  • drupal.org/project/relaxed
slide-62
SLIDE 62

Decoupled Drupal and developer experience

6

slide-63
SLIDE 63

Site or repository built in Drupal Decoupled application

Web services Decoupled application HTTP client

HTTP request HTTP response

slide-64
SLIDE 64

Web services Decoupled application SDKs and starter kits

HTTP request HTTP response

API-first distros

API-first distros, SDKs, and starter kits improve decoupled DX

slide-65
SLIDE 65

SDKs and starter kits

  • SDKs can help to make it easier for developers to

consume Drupal as a content service. These tend to be lightweight HTTP client wrappers which make requests on the developer's behalf and process responses.

  • Starter kits and references help jumpstart

implementations by providing an out-of-the-box experience for developers to get started right away.

slide-66
SLIDE 66

The Waterwheel ecosystem

slide-67
SLIDE 67

The Waterwheel ecosystem

  • Waterwheel is an emerging ecosystem of SDKs

designed to accelerate development of Drupal-backed applications in a variety of languages.

  • Currently, a helper SDK is available for JavaScript

as an initial release and a full SDK is available for Swift to power iOS, tvOS, and other Apple applications.

slide-68
SLIDE 68

The Waterwheel ecosystem

  • Waterwheel is intended to be a “translator” for

developers in other technologies: in other words, Waterwheel helps non-Drupalists “speak” Drupal.

slide-69
SLIDE 69

The Waterwheel ecosystem

  • github.com/acquia/waterwheel.js
  • github.com/kylebrowning/waterwheel.swift
  • drupal.org/project/waterwheel
  • github.com/acquia/ember-drupal-waterwheel
  • github.com/acquia/ember-waterwheel-app
  • github.com/acquia/react-waterwheel-app
slide-70
SLIDE 70

API-first distributions

  • An ecosystem of distributions oriented for

developers consuming decoupled Drupal is

  • emerging. The most prominent distributions are

Reservoir and Contenta.

  • github.com/acquia/reservoir
  • github.com/contentacms/contenta_jsonapi
slide-71
SLIDE 71

Reservoir and Contenta

slide-72
SLIDE 72

A good developer experience means that it's easy to provision APIs for a group of consumer applications

slide-73
SLIDE 73

A good developer experience means that it's easy for consumers to work with the provisioned APIs

slide-74
SLIDE 74

Decoupled Drupal and editorial experience

7

slide-75
SLIDE 75

In-place editing

One of Drupal 8's core features is in-place editing. In short, you can edit fields in context.

Title Body

Lorem ipsum dolor sit a| Consectetur adipiscing elit lorem ipsum dolor sit amet.

Consectetur adipiscing elit lorem ipsum dolor sit amet. Read more

Lorem ipsum dolor sit a|

slide-76
SLIDE 76

Websites and responsive sites can both leverage in-place editing

In-place editing

Title Body

Lorem ipsum dolor sit a| Consectetur adipiscing elit lorem ipsum dolor sit amet.

Consectetur adipiscing elit lorem ipsum dolor sit amet. Read more

Lorem ipsum dolor sit a| On websites and responsive sites, in-place editing can still make perfect sense.

slide-77
SLIDE 77

Digital signage could leverage in-place editing if Drupal is responsible for rendering

In-place editing

Slogan Website URL

Mehr Pizza ess| www.drupizza.at

Digital signage could still be possible if and only if Drupal renders it as well rather than exporting data.

www.drupizza.at

Mehr Pizza ess|

slide-78
SLIDE 78

In-place editing

Title Body

Lorem ipsum dolor sit a| Consectetur adipiscing elit lorem ipsum dolor sit amet.

Consectetur adipiscing elit lorem ipsum dolor sit amet. Read more

Lorem ipsum dolor sit a| But what about single-page applications or zero interfaces that can't be controlled by Drupal?

Content edited solely in Drupal's administration layer

slide-79
SLIDE 79

Display and layout management

What about choosing layouts and managing displays

  • f content?

Choose a layout Consectetur adipiscing elit lorem ipsum dolor sit amet. Read more Brand About Work Team Blog

slide-80
SLIDE 80

Display and layout management

What about choosing layouts and managing displays

  • f content?

Choose a layout Consectetur adipiscing elit lorem ipsum dolor sit amet. Read more Brand About Work Team Blog

slide-81
SLIDE 81

Full content Teaser

Display and layout management

What about toggling between teaser and full content display modes in a decoupled context?

Consectetur adipiscing elit lorem ipsum dolor sit amet. Ipsum amet sit adipiscing lorem consectetur elit. Elit adipiscing amet lorem. Brand About Work Team Blog Consectetur adipiscing elit lorem ipsum ... Read more Lorem ipsum dolor sit amet consectetur ... Read more Brand About Work Team Blog

slide-82
SLIDE 82

Editorial preview

  • What about accessing or previewing unpublished
  • r draft content?
  • Currently, previewing a single piece of content on

a single Drupal site (workspaces soon!) is trivial for editors. No developer needed!

  • In a decoupled setting, content can only be

previewed directly on the device or through an emulator, which may result in lower fidelity.

slide-83
SLIDE 83

Editorial preview

If an editor wants a high-fidelity preview of content on their single-page application or native mobile application, developers are required, for now.

Spin up a new test environment Push new content (published or accessible) to that test environment Give the editor a URL to inspect or a new app to install Editor can access high-fidelity decoupled preview

slide-84
SLIDE 84

Decoupled Drupal means we need to think about content in a more structured way

slide-85
SLIDE 85

Decoupled Drupal means we may need to accept that full visual control is impossible

slide-86
SLIDE 86

Decoupled Drupal means many capabilities we are used to need to be exposed to consumers

slide-87
SLIDE 87

Epilogue

Drupal's new incongruity

8

slide-88
SLIDE 88

Drupal's new incongruity

Drupal's value proposition is becoming incongruous between the three personas: the user, the marketer, and the developer. Is this irreconcilable?

slide-89
SLIDE 89

Developer experience Marketer experience

Drupal's new incongruity

Websites Responsive Digital signage Wearables Set-top boxes Augmented reality Conversational Mobile

slide-90
SLIDE 90

Drupal's new incongruity

The developer– user axis The editor–user axis Better for developers Better for editors B e t t e r f

  • r

u s e r s "Better for users" increasingly means "better on more devices."

slide-91
SLIDE 91

Drupal's new incongruity

The developer– user axis The editor–user axis Better for developers Better for editors B e t t e r f

  • r

u s e r s A better outcome for users relies more on custom work by developers.

slide-92
SLIDE 92

Food for thought

  • We have to be prepared to accept that the ideal

future state of Drupal may not be anything close to what it is today.

  • We have to be prepared to accept that Drupal

may be made up of many disparate parts, each essential to a larger whole.

slide-93
SLIDE 93

This is the great test that will dictate the next decade of Drupal

slide-94
SLIDE 94

A multifaceted Drupal is a more future-proof Drupal

slide-95
SLIDE 95

Decoupled Drupal means Drupal's story has only just begun

slide-96
SLIDE 96

More decoupled Drupal at Vienna

  • Breaking Drupal out of the box with AR and

beacons (with hampercm) Wed, 27 Sep — 15:45-16:45 — Strauss

  • Decoupled site building: Drupal's next challenge

Thu, 28 Sep — 10:45-11:45 — Strauss

  • Decoupled Drupal and editorial bliss (mrjmd)

Thu, 28 Sep — 14:15-15:15 — Lehar 1

slide-97
SLIDE 97

Join us for contribution sprint

  • Mentored Core Sprint

Fri, 29 Sep — 09:00–18:00 — Stolz 2

  • First-time Sprinter Workshop

Fri, 29 Sep — 09:00–12:00 — Lehar 1, Lehar 2

  • General Sprint

Fri, 29 Sep — 09:00–18:00 — Mall #drupalsprints

slide-98
SLIDE 98

What did you think?

  • Evaluate this session

events.drupal.org/vienna2017/sessions/breaking- drupal

  • Take the survey!

surveymonkey.com/r/drupalconvienna

slide-99
SLIDE 99

Vielen Dank! • Thank you!

Preston So has been a web developer and designer since 2001, a creative professional since 2004, and a Drupal developer since 2007. As Director of Research and Innovation at Acquia, Preston leads new

  • pen-source and research initiatives and helms Acquia Labs, the

innovation lab featured in international press. Previously, Preston contributed to the Spark initiative in the Drupal project, co-founded the Southern Colorado Drupal User Group (est. 2008), and operated an award-winning freelance web and print design studio. Preston has presented keynotes at conferences on three continents in multiple languages. preston.so@acquia.com • @prestonso • #introdecoupleddrupal