TL;DR
- Video here: https://youtu.be/QsmeXMZ0foM
- Repo with slides: github.com/AmazeeLabs/bartik_graphql
On Friday 11th May, Amazee Labs hosted its first Amazeenar - a live video training session presented by Philipp Melab who demonstrated some of the capabilities of GraphQL with the Drupal module GraphQL Twig.
We started the webinar while a crowd joined live from over 13 countries around the world, including Belgium, Brazil, Canada, South Africa, and as far east as Thailand.
It felt exciting to have a community of enthusiastic people connecting from so many different locations across the globe. This once again reinforced that Drupal is really about coming for the code and staying for the community.
Philipp dove into the talk by giving us a quick introduction to GraphQL, with an example query for us to better understand the concept:
query {
node:nodeById(id: "1") {
title:entityLabel
related:relatedNodes {
title:entityLabel
}
}
}
Running this example GraphQL query would give us the following JSON response:
{
“node”: {
“title”: “Article A”,
“related” {
{ “title”: “Article B” },
{ “title”: “Article C” }
}
}
}
Inversion of control
Philipp then explained the need for decoupling, providing us with a good overview of the fundamental differences between standard Drupal and Decoupled Drupal, in which the control moves from a push approach to a pull approach.
React is great, but the inversion of control is crucial.
Enable the template to define its data requirements, allow's us to achieve a clear data flow with significantly increased readability and maintainability. The GraphQL Twig module allows us to add GraphQL queries to any Twig template, which is then processed during rendering and used to populate the template with data.
Philipp entertained the audience with a live working demo in which, together, we learnt how to enhance the default “powered by Drupal” block to pull in the username of user 1. He then blew our minds with an additional surprise - pulling in the current number of open bug issues for Drupal Core via the GraphQL XML submodule.
Catchup
Did you miss the webinar? Don’t fret; we recorded everything!
- You can watch the recording here: https://www.youtube-nocookie.com/QsmeXMZ0foM
- You can access the Drupal theme as well as the slides for the webinar here: github.com/AmazeeLabs/bartik_graphql
Amazee Labs would like to thank everyone who attended the live session, we enjoyed being able to share this with you, and we look forward to hosting another Amazeenar shortly.