Overriding auto-generated bundle names in the GraphQL schema

Created on 14 January 2025, 3 months ago

Problem/Motivation

Currently the GraphQL type names for bundles are derived from the Drupal entity type ID and bundle ID. For example an "Article" node bundle will be included as "NodeArticle". This makes a lot of sense, and this proper namespacing prevents collisions.

It would be great if we allow these to be overridden in the UI. Projects might not want to expose the internal entity type / bundle IDs for different reasons:

  • The IDs might be poorly chosen (e.g. containing typo's, using a language different than English, ...).
  • Legacy projects might have bundle IDs that have changed their meaning over time, and don't make sense any more in the current context.
  • How data is named internally is irrelevant for decoupled projects. A frontend dev without Drupal experience might not care about why some content is considered to be a "Node" and other content a "Paragraph".
  • Projects might want to have an easy to understand GraphQL API which exposes an Event type instead of a NodeEvent

For some use cases (such as entity queries) it is still useful to know the internal entity type IDs and bundle IDs. We can communicate these as comments in the GraphQL schema, similar to how we now do it for fields:

"""
{entity_type: node} {entity_bundle: article}
"""
type Article implements Node {}

Proposed resolution

We can add an input field to the bundle section of the GraphQL server form.

  • The input field is disabled when the bundle is not exposed.
  • The auto-generated type name is shown as a placeholder, so site builders can see what will be included in the schema.
  • If a different type is entered in the field, this will be used instead.

User interface changes

The bundle form will have an additional input field for every bundle to enter a type name.

API changes

Bundle types will include a comment showing the originating entity type ID and bundle ID

Data model changes

GraphQL server configuration entity will store the overridden type names.

Feature request
Status

Active

Version

1.0

Component

Code

Created by

🇧🇬Bulgaria pfrenssen Sofia

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024