Overview

I tried GraphQL with Drupal, so this is a personal note for future reference. The following document was helpful.

https://drupal-graphql.gitbook.io/graphql/

This assumes Drupal installed on Amazon Lightsail.

Module Installation

Install the following module.

https://www.drupal.org/project/graphql

However, it was necessary to install the following module beforehand.

https://www.drupal.org/project/typed_data

As a result, the installation was completed with the following commands.

cd /home/bitnami/stack/drupal
composer require 'drupal/typed_data:^1.0@beta'
composer require 'drupal/graphql:^4.4'

Module Installation from GUI

I checked all three related modules below and installed them.

Configuration

Access the following URL.

/admin/config/graphql

Under “Create server”, I configured it as follows. I named it test_server.

Explore

Access the following URL.

/admin/config/graphql/servers/manage/test_server/explorer

You will be redirected to the following screen.

Let’s try the following query.

{
  articles {
    total
  }
}

The following result is obtained.

{
  "data": {
    "articles": {
      "total": 5054
    }
  }
}

Summary

In the future, I would like to investigate usage methods with custom schemas as well. I hope this serves as a useful reference.