protected function CommentSchemaExtension::addCommentFields in Open Social 10.3.x
Same name and namespace in other branches
- 10.2.x modules/social_features/social_comment/src/Plugin/GraphQL/SchemaExtension/CommentSchemaExtension.php \Drupal\social_comment\Plugin\GraphQL\SchemaExtension\CommentSchemaExtension::addCommentFields()
Registers type and field resolvers in the shared registry.
Parameters
\Drupal\graphql\GraphQL\ResolverRegistryInterface $registry: The resolver registry.
\Drupal\graphql\GraphQL\ResolverBuilder $builder: The resolver builder.
1 call to CommentSchemaExtension::addCommentFields()
- CommentSchemaExtension::registerResolvers in modules/
social_features/ social_comment/ src/ Plugin/ GraphQL/ SchemaExtension/ CommentSchemaExtension.php
File
- modules/
social_features/ social_comment/ src/ Plugin/ GraphQL/ SchemaExtension/ CommentSchemaExtension.php, line 39
Class
- CommentSchemaExtension
- Adds comment data to the Open Social GraphQL API.
Namespace
Drupal\social_comment\Plugin\GraphQL\SchemaExtensionCode
protected function addCommentFields(ResolverRegistryInterface $registry, ResolverBuilder $builder) {
$registry
->addFieldResolver('Comment', 'id', $builder
->produce('entity_uuid')
->map('entity', $builder
->fromParent()));
$registry
->addFieldResolver('Comment', 'author', $builder
->produce('entity_owner')
->map('entity', $builder
->fromParent()));
$registry
->addFieldResolver('Comment', 'bodyHtml', $builder
->compose($builder
->produce('field')
->map('entity', $builder
->fromParent())
->map('field', $builder
->fromValue('field_comment_body')), $builder
->produce('field_renderer')
->map('field', $builder
->fromParent())));
$registry
->addFieldResolver('Comment', 'created', $builder
->fromPath('entity:comment', 'created.value'));
}