Book Image

Drupal 10 Development Cookbook - Third Edition

By : Matt Glaman, Kevin Quillen
Book Image

Drupal 10 Development Cookbook - Third Edition

By: Matt Glaman, Kevin Quillen

Overview of this book

This new and improved third edition cookbook is packed with the latest Drupal 10 features such as a new, flexible default frontend theme - Olivero, and improved administrative experience with a new theme - Claro. This comprehensive recipe book provides updated content on the WYSIWYG (What You See Is What You Get) editing experience, improved core code performance, and code cleanup. Drupal 10 Development Cookbook begins by helping you create and manage a Drupal site. Next, you’ll get acquainted with configuring the content structure and editing content. You’ll also get to grips with all new updates of this edition, such as creating custom pages, accessing and working with entities, running and writing tests with Drupal, migrating external data into Drupal, and turning Drupal into an API platform. As you advance, you’ll learn how to customize Drupal’s features with out-of-the-box modules, contribute extensions, and write custom code to extend Drupal. By the end of this book, you’ll be able to create and manage Drupal sites, customize them to your requirements, and build custom code to deliver your projects.
Table of Contents (17 chapters)

Building APIs with Drupal

Drupal 10 comes with several awesome features to help facilitate building out RESTful APIs using the core Serialization and JSON:API modules. These enable you to build headless and/or decoupled solutions that can still interact with and query for data in Drupal.

In this chapter, we will look at how to do the following:

  • Fetching data from Drupal using JSON:API (https://jsonapi.org/)
  • Using POST to create data with JSON:API
  • Using PATCH to update data with JSON:API
  • Using DELETE to remove data with JSON:API
  • Using Views to provide custom data sources
  • Using OAuth methods

The Serialization module provides a means of serializing data to or deserializing from formats such as JSON and XML. The RESTful Web Services module then exposes entities and other resource types through web APIs. Operations done over RESTful resource endpoints use the same create, edit, delete, and view permissions that would be used in a non-API context. The...