Drupal and GraphQL

nikhilsukul
rdatar
nirvana_u
shridhars

GraphQL, has been created by Facebook for complex data requirements based queries. Decoupling your content management system enables front-end developers to fully control an application or site's rendered markup and user experience. It also helps to give the applications an enhanced user experience.

One of the most difficult issues facing front-end developers is network performance with REST.

Currently, the only way to solve this problem is to create custom API endpoints (e.g. in Views) that comprehensively provide all the data needed by the client in a single response to minimize round trips. Relying on a single endpoint, updating it requires modifying all the JavaScript that relies on that endpoint and ingests its response. These endpoint management issues can force the front-end developer to depend on work the back-end developer must complete, which creates bottlenecks in decoupled teams.

Decoupling hence, reveals the need to investigate better ways of exposing data to the client side. As our pages and applications become ever more component-driven, the complexity of the queries we must perform and our demands on their performance increase. What if we could extract only the data we need by writing queries that are efficient and performant by default? Sebastian Siemssen proposes using Facebook's GraphQL (see demo video and project on drupal.org) due to the client's explicit definition of what schema to return and the use of consolidated queries which break apart into smaller calls and recombine for the response, thereby minimizing round trips.

It means that decoupled sites will enjoy better overall performance and give front-end developers a better experience: very few round trips to the server, no need for custom endpoints, no need for versioning, and no dependence on back-end developers.

Disadvantage: Projects and the architecture can get messy, fast and confusing for developers that come on/off the project; necessitating a need for a strong governance model and a well thought out and communicated architecture for how to deal with the decoupled nature of the project.

 

What we will discuss?

  • What is GraphQL?

  • Why to use GraphQL?

  • How GraphQL works?

  • Drupal Application - Real world scenarios

  • Creating contributed module for this?

  • Detailed Demo to show how Drupal can interact with GraphQL and its benefits to the site

Session Track

Front End

Experience Level

Intermediate

Drupal Version