Unsupported type for entity types with similar machine names (private_message etc)

Created on 9 January 2025, about 2 months ago

Problem/Motivation

When we enable similar machine name entities on graphql_compose we get the "Unsupported type" for the entity reference fields. This is happening for example when we enable the entity types "message, private_message, private_message_thread" together.

The GraphQL says "[UnsupportedType!]!" for such fields althouth it finds the new types normally.

Steps to reproduce

1) On a fresh Drupal install modules message, private_message and graphql_compose.
2) Create some bundles for the "message" entity type above.
3) Create a simple module that enables graphql_compose for entities message, private_message, private_message_thread (module attached as zip).
4) Enable module graphql_compose_private_messages and graphql_compose_messages
5) Enable the graphql_compose schema on Drupal Graphql and add the types above to the schema (/admin/config/graphql_compose/)
6) Go to the GraphQL Documentation on explorer and check for the "privateMessages" field. It is an "[UnsupportedType!]!" although the new entity types are normally supported.

Example commands to use the attached zip file with ddev:

unzip test_pm_drupal.zip
cd test_pm_drupal

ddev start
ddev composer install
ddev import-db --file database.sql.gz
# ddev drush cim -y

# Open https://test-pm-drupal.ddev.site/admin/config/graphql/servers/manage/graphql_compose_server/explorer

Proposed resolution

- Not sure if this is happening due to the naming patterns. Because in this case the machine names in GraphQL are "MessageXXX, PrivateMessagePrivateMessage, PrivateMessageThreadPrivateMessageThread".
- Tried to use custom "id" and "prefix" on the "@GraphQLComposeEntityType" annotation but did not solve the issue.

Remaining tasks

🐛 Bug report
Status

Active

Version

2.3

Component

Code

Created by

🇬🇷Greece TheodorosPloumis Greece

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

Comments & Activities

  • Issue created by @TheodorosPloumis
  • 🇦🇺Australia almunnings Melbourne, 🇦🇺

    Will take a look at this in the next day or so.
    Had second baby, now this baby suffers!

    🥲

  • 🇦🇺Australia almunnings Melbourne, 🇦🇺

    Add a MessageTemplate type to bridge the `template` in Message

    
    declare(strict_types=1);
    
    namespace Drupal\graphql_compose_messages\Plugin\GraphQLCompose\EntityType;
    
    use Drupal\graphql_compose\Plugin\GraphQLCompose\GraphQLComposeEntityTypeBase;
    
    /**
     * {@inheritdoc}
     *
     * @GraphQLComposeEntityType(
     *   id = "message_template",
     *   base_fields = {
     *     "label" = {},
     *     "langcode" = {},
     *   },
     * )
     */
    class MessageTemplate extends GraphQLComposeEntityTypeBase {
    
    }
    
    

    Remove the prefix from PrivateMessage and PrivateMessageThread (These entities don't have bundles)

    That should get your entity references to resolve.

    As for the overall functionality of your modules, No idea, choose your own adventure! :D
    Have fun!

Production build 0.71.5 2024