This project is not covered by Drupal’s security advisory policy.
This module adds a GraphQL schema extension and relevant resolvers to enable CRUD (Create, Read, Update, Delete) operations for Drupal Books. In particular, it allows creating book outlines and attaching book pages to other pages, which is currently unsupported via other methods, like JSON:API.
Features
The module adds 2 kinds of queries: books returns all stored books and book(id) returns a particular book given its node ID.
It also adds 3 mutations: createBook(data), updateBook(id, data), and deleteBook(id).
Additional Requirements
To use the module, you will need to install and enable Book, GraphQL, and GraphQL Book modules. All pre-requisites should be installed automatically if this module is installed using composer.
Note: GraphQL 4.5 dependencies have a minimum stability bug in the requirements, so if it throws an error about specifying minimum stability, you may need to manually install its dependency `typed_data` module first:
composer require 'drupal/typed_data:^1.0@beta'
Post-Installation
Configure a GraphQL server as follows:
- In the Drupal administrator dashboard, go to Configuration -> GraphQL -> Servers
- Click "Create server"
- Give it a name, e.g. "Book endpoint"
- Choose schema to be "Composable Book schema"
- Under Schema configuration > Enabled extensions, tick the "Composable Book extension" (due to a bug in the GraphQL module, sometimes this gets reset on the first server save, so after saving it, click edit and come back to check this is still ticked)
- For endpoint, add "/graphql" unless you already have another GraphQL server running and want to separate them
- Set the remaining settings for your use case (it's also fine to leave them as default) and click "Save"
See the GraphQL module documentation for general usage guidance: README - GraphQL
For details about the GraphQL schema made available by this project, see the files under graphql/ in the project source code.
Supporting documentation
Book link fields exposed by this module are documented in BookOutlineStorageInterface::loadMultiple
Example usage
All Python code is prefixed with:
graphql_endpoint = "https://your_drupal.site/graphql"
from requests import session
with session() as session:
List all books
| GraphQL query | Python request | Example response |
|---|---|---|
|
|
|
Create a new book page
| GraphQL query | Python request | Example response |
|---|---|---|
|
|
|
Make the new course page into a book (creating a new book outline)
| GraphQL query | Python request | Example response |
|---|---|---|
|
|
|
Create a child content page
| GraphQL query | Python request | Example response |
|---|---|---|
|
|
|
Project information
Minimally maintained
Maintainers monitor issues, but fast responses are not guaranteed.- Project categories: Decoupled, Developer tools, Integrations
- Ecosystem: GraphQL
- Created by vidminas on , updated
This project is not covered by the security advisory policy.
Use at your own risk! It may have publicly disclosed vulnerabilities.
