OpenSense Labs: Different options of decoupling Drupal

Different options of decoupling Drupal
Shalini Rawat
Mon, 08/10/2020 – 17:36

In this world of growing interfaces and APIs, content plays a significant role and great user experiences begin with great content. Certainly, wearables, conversational interfaces, IoT, and more have begun to establish the changes in how we experience the internet, making alterations in the digital marketplace. Therefore, to keep up the pace, organizations need to adopt front-end technologies such as AngularJS, React JS, etc. that can deliver the content at a fast speed. Decoupled Drupal (or headless Drupal) is one such solution that has been gaining ground lately and is being considered as a holy-grail that exhibits innovative strength to produce exceptional digital experiences. 

Grey background with Drupal at the center

The role of the website is not limited to the creation of the content. In other words, the website is responsible to deliver the content in a user-friendly manner across all devices. Keeping this responsibility in mind, more and more websites are opting for a decoupled approach and preferring a strong content store in Drupal And probably that is why you are here. However, the most complex question remains – how to decouple Drupal. Therefore, in this post, we will be gaining more insight into different ways of implementing decoupled Drupal.

Ways to Decouple Drupal

In a traditional web project, Drupal is used to manage the entire content and to present it. Since Drupal is a monolithic system, therefore it maintains entire control over the presentation as well as data layers. Traditional Drupal has been an excellent choice for editors who wish to take full control over the visual elements on the page. Not to mention, traditional Drupal open door to access features such as in-place editing and layout management. 

There are certain factors that are required to be considered by a technical decision maker before thinking to implement the Decoupled approach. These factors are the implications whether the effort to decouple Drupal is the perfect fit for your organization or not. Therefore, let’s take a look at the factors that should be a part of the decision making process.

  • First things first, do you have separate backend and front-end development resources? 
  • Are you building a native app and want to use Drupal to manage your content, data, users, etc.? 
  • Do you envision publishing content or data across multiple products or platforms?
  • Is interactivity itself a primary concern?
  • Does working around Drupal’s rich feature set and interface offer more work in the long run?
  • Do you want the hottest technology?
  • If your organization complies with the above mentioned factors, the organization is ready for the decoupling process. 

There are two approaches for decoupling drupal depending on the preferences and requirements. These include progressively decoupled, and fully decoupled.

Dark background with bright text color
Source: Drupal.org

Progressively Decoupled Drupal

Progressively decoupled Drupal is required when an additional layer called JavaScript is used to deliver a highly interactive end-user experience. In progressively decoupled Drupal, a JavaScript framework is used as a layer on top of the existing Drupal front end. The former is responsible for nothing more than rendering a single block or component on a page or it may render everything within the page body. The progressive decoupling model lies on a spectrum; the less of the page committed to JavaScript, the more editors can take control over the page through Drupal’s administrative capabilities.

Fully Decoupled Drupal

Fully decoupled Drupal can be implemented in two ways, namely Fully decoupled app and Fully decoupled static site. 
Fully decoupled Drupal web app involves a complete separation of concerns between the presentation layer and all other aspects of the CMS. In this approach, the CMS becomes a data provider, and a JavaScript application along with server-side rendering is held responsible to render and markup, communicate with Drupal via web service APIs. Despite the unavailability of key functionality like in-place editing and layout management, fully decoupled Drupal app captivates the attention of developers who want greater control over the front end and who are already experienced with building applications in frameworks such as Angular, React, Vue.js, etc. 

On the contrary, JAMstack (JavaScript, APIs, Markup) offers an alternative to the complexities of JavaScript development. It helps in building fully decoupled Drupal static sites. The prime and obvious reason behind the idea is improved performance, security, and reduced complexity for developers.

Front end technologies

In the world of software development, whatever is built around falls into two categories: front-end technology and back-end technology. Front-end technology is everything that is seen by the user and the process that is happening in the background. On the contrary, all the behind-the-scenes activity that is responsible to deliver data and speed to run a screen is considered back-end technology. 

The development of front-end technology is crucial for any business application that wants to succeed and sustain itself in the digital marketplace. It is possible to have the most structured back-end programming to strengthen your application, however, the front-end is what people see and mostly care about.

Therefore, for your consideration, we have rounded up the best front-end technologies that a front end developer can use with Drupal to derive the best outcomes. 

Desktop encircled by 4 front-end technologies

React

React is a JavaScript library that is used to create interactive user interfaces (UIs). It is one of the most powerful and highly used front-end technologies, supported and maintained by the tech giant Facebook. The React holds the capability to split the codes into components to further enable developers with code reusability and fast debugging.  The appellations produced are SEO friendly and highly responsive.
Some of the prominent websites and web applications that use React as front-end technology include Airbnb, Reddit, Facebook, NewYork Times, BBC, etc.

Why connect with Drupal?

  • The combination of React and Drupal can be used to create amazing digital experiences. However, it is quite challenging to know how to leverage the strengths of both react and Drupal.
  • The one-way data flow of React helps in shaping the web page in accordance with the data that is sent from Drupal’s RESTful API.

Gatsby

Gatsby is basically an open-source, modern website framework that helps build performance into every site by leveraging the latest web technologies such as React and GraphQL. Moreover, Gatsby is used to creating blazing-fast apps and websites without needing to become a rockstar. It uses powerful pre-configuration to build a website that uses only static files for incredibly fast page loads, service workers, code splitting, etc.
 
Why connect with Drupal?

  • There is no better option than Gatsby to create an enterprise-quality CMS for free, paired with great modern development experience. Not to mention, it offers all the benefits of the so-called JAMstack, like performance, scalability, and security.
  •  Static site generators like Gatsby can do fireworks by pre-generating all the pages of the website, unlike dynamic sites that render pages on-demand, thereby reducing the need for live database querying. As a result, performance is enhanced and overheads are reduced. This enhances the performance and brings down the maintenance cost.

Angular

Angular is an open-source, JavaScript front-end technology. Ever since the advent of this technology in 2009, it has been continuously gaining immense popularity for the advantages that it delivers to the businesses. Angular is supported by a large community and maintained by the tech giant Google. This open-source is readable and constant and enables businesses with various high performing apps.
Paypal, Gmail, and The Guardian are some of the examples that use Angular as the front end technology.

Why connect with Drupal?

  • The powerful combination of Drupal with Angular will allow you to move display logic to the client-side and streamline your backend, thus resulting in a super speedy site.
  • HTML never goes out of date and is always demanded by web developers and designers because of its simplicity, clarity, and intuitivism in its code structure. Angular makes use of HTML to define user interfaces, hence letting the organizations build interactive web applications that are highly functional and hard to break.

Vue

Vue is a JavaScript library that is used for developing distinct web interfaces and to create single-page applications. The core library of Vue solely focuses on the view layer, therefore providing convenient integration with other libraries and tools to achieve the pre-decided or desired outputs. Vue is not just a technology rather it is a proud ecosystem that is easily adaptable as it is lightweight. 

Why connect with Drupal?

  • With Drupal and Vue combination, developers have an upper hand to request and store Drupal content as data objects with the help of the official Vue-Resource plugin.
  • When combined with Vue, Drupal becomes competent to exhibit its magic at the back-end while the compelling features of the Vue handle the client-side. Vue’s component system is one of the powerful features that allow large-scale application building, comprising small and self-contained reusable components.

Decoupled Drupal ecosystem

The world of Decoupled Drupal is a compendium of a myriad of unique modules and features that can help transform the way you retrieve and manipulate information. Amongst which Rest, JSON: API, and GraphQL are the most important as well as the common modules when it comes to decoupled Drupal implementation.  So, let’s take a birds-eye view of each one of them-

RESTful Web Services

Web Services holds the responsibility to allow other applications to read and update information on your site via the Web. REST is one of the ways of making Web Services available on your site. Unlike other techniques, it encourages developers to rely on HTTP methods (such as GET and POST) to operate on resources (data managed by Drupal). RESTful web services is a module that provides a customizable, extensible RESTful API of data managed by Drupal. The module enables you to create an interaction with any content entity (nodes, users, comments) as well as watchdog database log entries. 

JSON: API

JSON: API is designed with an intent to minimize the number of requests as well as the amount of data that is transmitted between clients and servers. And guess what, this efficiency comes without any compromise relating to readability, flexibility, or discoverability. The moment you enable the JSON: API module is the moment you immediately gain a full REST API for every type in your Drupal application. JSON: API works on the principle that the module should be production-ready ‘’out of the box”. To clarify, the module is highly inflexible in nature, wherein everything is pre-fixed. Be it about the location where the resources will reside, or what methods are immediately available on them. JSON: API leaves access control to Drupal Core’s permissions system. 

GraphQL

The GraphQL Drupal module is used to raise a query or mutate (update/delete) any content or configuration using the official GraphQL query language. This particular module is considered as an extremely powerful tool which opens the door for Drupal to be used in a multitude of applications. Also, plays a crucial role in tools like GraphQL to implement auto-completion. This module can be used as a foundation for building your own schema through custom code or you can use and extend the generated schema using the plugin architecture and the provided plugin implementations form the sub-module.

In addition to these, the shift of responsibility has given rise to the development of some other modules to better serve the content and data. Let’s take a glance at them.

  • You can use Webform REST module to retrieve and submit web forms via REST.
  • If you wish to extend core’s REST Export views display to automatically convert any JSON string field to JSON in the output, REST Export Nested module is the best option. 
  • Overriding the defaults that are preconfigured upon the installation of JSON: API module sounds easy with the JSON: API Extras.
  • For easy ingestion of content by other applications, Lightning API provides a standard API that primarily makes use of the json:api and OAuth2 standards via the JSON: API and Simple Oauth modules.
  • To build an integration between GraphQL and Search API modules, GraphQL Search API module can be useful.
  • Subrequest module tells the system to execute several requests in a single bootstrap and then return all the things.
  • Contenta JS module is necessary for Contenta.js to function properly.
  • There is an OpenAPI module in Drupal that can integrate well with both core REST and JSON: API for documentation of available entity routes in those services. 
  • Schemata module that provides schemas can be used for facilitating generated documentation and generated code.

Check out more such modules in the decoupled Drupal ecosystem here

Conclusion 

To conclude, decouple Drupal is an interesting approach that can help you build feature-rich interactive websites or build content hubs. There is a lot of talk about headless Drupal in the market and there is no doubt why companies are going gaga over it. In today’s world, end-users look forward to highly interactive websites that can pop out results in a jiff. Moreover, content needs to be made available at all touch-points in harmony. The decoupled Drupal solves these problems by creating different layers for presentation and data.

However, it is equally important to dig in certain minute downsides to it as well and carefully consider them before taking the decoupled path.

Got a question? Feel free to ping us at hello@opensenselabs.com and our experts will help you embark on your Drupal project.

blog banner
Road and a flyover going in different directions

blog image
An open door with the nature in the background

Blog Type
Is it a good read ?
On