Play to your strengths; using GraphQL with a WordPress backend

WordPress is amazing, but sometimes the client just needs a custom site built. If you’re a javascript developer, you’d love to be able to reach for ${JS_FRAMEWORK} to build out the site, but don’t want to write PHP code or deal with having to write a custom backend data management either.

The best solution may be to split the front end from the back end, entirely. WordPress has a fantastic admin dashboard and the UX for adding and updating content is very simple for non-techies to grasp. How about we let the end users continue to use the WordPress dashboard to edit content, and we’ll build a snazzy the front end using javascript. The lone problem then becomes ‘how do we get the data?’.

The WP JSON API is nifty and could work for smaller projects, but eventually all of those network requests get a little overwhelming. Enter GraphQL. GraphQL is a query language spec developed by Facebook (don’t hold that against them…) that allows you to request what you need for each request. It cuts down on HTTP traffic and makes the dev experience a heckuva lot nicer.

In this talk, we’ll do a crash course on GraphQL and the ecosystem that’s been built around it, making use of the WP GraphQL plugin, and building out a front end using Stencil JS, a web component compiler* (*=BONUS DEV CONTENT!)

Speaker