Combining All the Things: GraphQl Middleware to Give All Your Decoupled API's a Single Home.

Daniel Rogers, Nick Rigby

A decoupled, API-first architecture can be fast and efficient. But it can also generate lots of different things in the oddest places: calendar events over here, a newsroom over there, and loads of actual content in a whole bunch of places. And if you’re a developer interacting directly with multiple separate APIs, frontend builds can get complicated quickly as dev teams and stakeholders struggle to understand how to access each different API in your ecosystem.

Enter Middleware. In this session, we untangle the mess of decoupling by creating a simple node based (node.js) Express Middleware server that will combine all of your multiple API's into a single endpoint, all query-able by GraphQl.

Imagine working on a single API that combines all of the separate API endpoints into a common schema, and becomes accessible via the powerful, and awesome GraphQl syntax.

Some benefits of Middleware/GraphQl:

Unlike (most) REST endpoints, use a single, simple HTTP request to make multiple requests, asking for only the fields needed.
Simplify, streamline and standardize JSON responses for frontend development.
Ability to add custom access, and caching functionality unique to the middleware.
Ability to provide custom callbacks on fields/entities/etc.
Ability to build custom callbacks to combine data from different API's into a single combined endpoint for your frontend clients.
And more!
In this session we will share simple examples of:

Single endpoint interacting with D7 site.
Single endpoint interacting with D8 site.
Single endpoint interacting with agnostic public API.
Single endpoint that combines several API endpoints into a single call, and subsequent result set
Plus, we’ll discuss common pitfalls, and some ideas that may help you build an awesomely powerful combined API!

Example middleware Repo: https://github.com/idfive/govcon-2018-middleware/settings

Example middleware sandbox: http://govcon-2018-starships.herokuapp.com/graphql

https://www.drupalgovcon.org/2018/program/sessions/combining-all-things-graphql-middleware-give-all-your-decoupled-apis-single

Drupal is a registered trademark of Dries Buytaert.