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

CommentFileSizeAuthor
test_pm_drupal.zip40.63 MBtheodorosploumis

Comments

theodorosploumis created an issue. See original summary.

almunnings’s picture

Assigned: Unassigned » almunnings
Category: Bug report » Support request

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

🥲

almunnings’s picture

Status: Active » Closed (works as designed)

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!