API-first initiative

Mateu Aguilรณ Bosch
Drupal.org: e0ipso
@e0ipso
 

Senior Developer
Lullabot logo

Wim Leers
Drupal.org: Wim Leers
@wimleers
wimleers.com

Principal Software Engineer, OCTO
Acquia logo

Quick questionnaire! ๐Ÿ“

  • Who has worked on decoupled Drupal projects?
    • If no, would you like to in the future?
  • Did you use
    • Core's REST module?
    • JSON API or GraphQL?
โœ๏ธ

Vision

I believe that it is important to have first-class web services in Drupal out of the box in order to enable top-notch APIs and continue our evolution to become API-first.
โ€” Dries Buytaert

An unparallelled API-first platform

All data available:

  • RESTfully
    • in any format (JSON, HAL+JSON โ€ฆ)
    • in multiple flavors ("HTTP purist", jsonapi.org โ€ฆ)
  • non-RESTfully
    • via GraphQL
    • via CouchDB protocol, for replication & syncing

โ€ฆ using any authentication mechanism (Cookie, OAuth 2.0, etc.)

People want need this!


We talked about this a lot:

  • DrupalCon Baltimore: 12 sessions, 1 training
  • Decoupled Dev Days
  • DrupalCon Nashville: 1 summit and MANY sessions
  • โ€ฆ

Goals

Must have
  • Make D8 REST usable โœ…
  • Make D8 REST best-in-class ๐Ÿ‹๏ธ๐Ÿ‹๏ธ๐Ÿ‹๏ธ
  • Excellent docs via OpenAPI ๐Ÿ‹๏ธ๐Ÿ‹๏ธ๐Ÿ‹๏ธ
Should have
  • JSON API โœ…
  • GraphQL ๐Ÿ‹๏ธ๐Ÿ‹๏ธ๐Ÿ‹๏ธ๐Ÿ‹๏ธ๐Ÿ‹๏ธ
  • Workflows: UUID and revision
Could have
  • OAuth 2.0 support โœ…
  • CouchDB support ๐Ÿ‹๏ธ๐Ÿ‹๏ธ

Goals (6 months ago)

Must have
  • Make D8 REST usable โœ…
  • Make D8 REST best-in-class ๐Ÿ‹๏ธ๐Ÿ‹๏ธ
  • Excellent docs via OpenAPI ๐Ÿ‹๏ธ๐Ÿ‹๏ธ
Should have
  • JSON API โœ…
  • GraphQL ๐Ÿ‹๏ธ๐Ÿ‹๏ธ
  • Workflows: UUID and revision
Could have
  • OAuth 2.0 support ๐Ÿ‹๏ธ
  • CouchDB support ๐Ÿ‹๏ธ๐Ÿ‹๏ธ

Goals (12 months ago)

Must have
  • Make D8 REST usable โœ…
  • Make D8 REST best-in-class ๐Ÿ‹๏ธ
  • Excellent docs via OpenAPI ๐Ÿ‹๏ธ
Should have
  • JSON API ๐Ÿ‹
  • GraphQL
  • Workflows: UUID and revision
Could have
  • OAuth 2.0 support
  • CouchDB support ๐Ÿ‹๏ธ

Why?

REST API
  • Multiple formats
  • Non-entity REST resources
  • Very configurable
JSON API โ†’ stable 8.3 contrib โ†’ mature 8.4โ€“5 contrib โ†’ core 8.6
  • Opinionated spec โ‡’ better tooling, less bikeshedding
  • Collection support โ‡’ custom REST export views
  • Not configurable: any entity that Entity Access allows
GraphQL โ†’ stable 8.4โ€“5 contrib
Great for UI components to fetch only necessary data!
Excellent docs via OpenAPI โ†’ stable 8.4โ€“5 contrib
Starting is too painful โ‡’ docs with interactive examples

Roadmap

Current focus

REST API โ†’ best in class
Missing: translations, modifying config, file uploads ๐ŸŽ‰.
Much is blocked on subsystems in Drupal 8.
JSON API โ†’ mature 8.4โ€“5 contrib โ†’ core 8.6
Missing: comprehensive test coverage, plus ๐ŸŽ‰ the above.
GraphQL โ†’ stable 8.4โ€“5 contrib
Missing: more sites using it, to stabilize ๐ŸŽ‰.
Excellent docs via OpenAPI
12 mo ago: competition (rest_api_doc, Schemata, Docson, OpenAPI)
Now: standardizing on OpenAPI!

Team

  • Wim Leers (Coordinator)
    REST + Serialization + JSON API
  • e0ipso(Coordinator)
    JSON API + OAuth 2.0 + Subrequests + Consumers + Decoupled Router + โ€ฆ
  • gabesullice JSON API
  • tedbow OpenAPI + REST + Serialization + jsdrupal
  • richgerdes OpenAPI
  • pmelab GraphQL
  • dawehner jsdrupal + REST + Serialization + JSON API
  • โ€ฆ
Help wanted ๐Ÿ˜ธ

Ecosystem

Tooling

github.com/acquia/waterwheel.js
github.com/acquia/waterwheel.swift

Distributions

contentacms.org
Productivity boost for Decoupled Drupalists

Outstanding challenges

Content Staging
previews of decoupled consumers
Improve DX further
entity validation error responses, field aliasing โ€ฆ
Dogfooding
let Drupal consume HTTP APIs (๐Ÿค JS Initiative)
API versioning
๐Ÿ˜ฑ
โ€ฆ

Open discussion

You are too quietโ€ฆ

How much of this should we have in Drupal core?

What are the best places to start dogfooding this?

What features are you excited about? Why?

What authentication providers should we add?

Do we support decoupled admin interfaces?