- Issue created by @mcanada
- π¨πSwitzerland ayalon
Is the module "dynamic_reference" installed? Try restarting your webserver to clear the APCU cache.
- π¨πSwitzerland ayalon
I can't. The module has now dependancy on this module. Something with your entity model (TypedDataManager) is fishy.
I've got the same error. It is with a dynamic_entity_reference when it goes wrong. The error talks about 'dynamic_entity' and that is where it goes wrong. The module is not 'dynamic_entity', but 'dynamic_entity_reference'.
It seems to me that is a problem with the dynamic_entity_reference module, since they have this code in their 'DynamicEntityReference.php' file:
* @DataType( * id = "dynamic_entity_reference", * label = @Translation("Dynamic entity reference"), * definition_class = "\Drupal\dynamic_reference\DataDynamicReferenceDefinition" * )
If i manually edit this and clear caches, the error is gone, but then a different error occurs:
Drupal\Component\Plugin\Exception\PluginNotFoundException
The "dynamic_entity" plugin does not exist. Valid plugin IDs for Drupal\Core\TypedData\TypedDataManager are: dynamic_entity_reference, ...Drupal\Core\Plugin\DefaultPluginManager:53
doGetDefinition
Drupal\Core\Plugin\DefaultPluginManager:25
getDefinition
Drupal\Core\TypedData\TypedDataManager:β115
createDataDefinition
Drupal\dynamic_entity_reference\DataDynamicReferenceDefinition:β31
create
Drupal\Core\TypedData\DataReferenceDefinition:β42
createFromDataType
Drupal\Core\TypedData\TypedDataManager:β120
createDataDefinition
Drupal\graphql_core_schema\EntitySchemaBuilder:β879
getDataPropertyType
Drupal\graphql_core_schema\EntitySchemaBuilder:β456
getFieldItemType
Drupal\graphql_core_schema\EntitySchemaBuilder:β387
getFieldItemListType
Drupal\graphql_core_schema\EntitySchemaBuilder:β766
createEntityFields
Drupal\graphql_core_schema\EntitySchemaBuilder:β532
addContentEntityType
Drupal\graphql_core_schema\EntitySchemaBuilder:β586
generateTypeForEntityType
Drupal\graphql_core_schema\Plugin\GraphQL\Schema\CoreComposableSchema:β176
getSchemaDefinition
Drupal\graphql_core_schema\Plugin\GraphQL\Schema\CoreComposableSchema:β381
getSchemaDocument
Drupal\graphql_core_schema\Plugin\GraphQL\Schema\CoreComposableSchema:β303
getSchema
...It seems to me that is a problem with the dynamic_entity_reference module, since they have this code in their 'DynamicEntityReference.php' file:
* @DataType( * id = "dynamic_entity_reference", * label = @Translation("Dynamic entity reference"), * definition_class = "\Drupal\dynamic_reference\DataDynamicReferenceDefinition" * )
If i manually edit this and clear caches, the error is gone, but then a different error occurs:
Drupal\Component\Plugin\Exception\PluginNotFoundException
The "dynamic_entity" plugin does not exist. Valid plugin IDs for Drupal\Core\TypedData\TypedDataManager are: dynamic_entity_reference, ...Drupal\Core\Plugin\DefaultPluginManager:53
doGetDefinition
Drupal\Core\Plugin\DefaultPluginManager:25
getDefinition
Drupal\Core\TypedData\TypedDataManager:β115
createDataDefinition
Drupal\dynamic_entity_reference\DataDynamicReferenceDefinition:β31
create
Drupal\Core\TypedData\DataReferenceDefinition:β42
createFromDataType
Drupal\Core\TypedData\TypedDataManager:β120
createDataDefinition
Drupal\graphql_core_schema\EntitySchemaBuilder:β879
getDataPropertyType
Drupal\graphql_core_schema\EntitySchemaBuilder:β456
getFieldItemType
Drupal\graphql_core_schema\EntitySchemaBuilder:β387
getFieldItemListType
Drupal\graphql_core_schema\EntitySchemaBuilder:β766
createEntityFields
Drupal\graphql_core_schema\EntitySchemaBuilder:β532
addContentEntityType
Drupal\graphql_core_schema\EntitySchemaBuilder:β586
generateTypeForEntityType
Drupal\graphql_core_schema\Plugin\GraphQL\Schema\CoreComposableSchema:β176
getSchemaDefinition
Drupal\graphql_core_schema\Plugin\GraphQL\Schema\CoreComposableSchema:β381
getSchemaDocument
Drupal\graphql_core_schema\Plugin\GraphQL\Schema\CoreComposableSchema:β303
getSchema
...- π¨πSwitzerland dulnan
I looked into this. There are two problems here:
First, the dynamic_entity_reference module has a broken annotation, as already spotted in #6:
https://git.drupalcode.org/project/dynamic_entity_reference/-/blob/3.x/s...
This should be fixed in the module itself, because the same error will happen every time one tries to load the definition of this data type.Second, even if this is fixed, there is this code in core that gets called when trying to get the definition for the "dynamic_entity_reference" data type: https://git.drupalcode.org/project/drupal/-/blob/11.x/core/lib/Drupal/Co...
This is the class that the DataDynamicReferenceDefinition class extends from. The method will remove the "_reference" from the string and then call ::create with "dynamic_entity", which is not a valid plugin ID.Because the schema builder tries to figure out the best possible type for an entity reference field, it tries to get the definitions of fields and items. That way a "field_image" results in a field in GraphQL with type "MediaImage", instead of a generic "Entity" interface.
I'll see if it's possible to work around these issues in the schema builder.
- Status changed to Fixed
4 months ago 6:26am 30 July 2024 - π¨πSwitzerland dulnan
I was able to add rudimentary support for this specific field type, even if its data definitions are broken. Because we don't (yet) support union types, the type of the field is always going to be "Entity".
- πΊπΈUnited States markdorison
Thank you for the fix @dulnan! Is there any way we could get a new release with this included?
Automatically closed - issue fixed for 2 weeks with no activity.