public function ResolverHelperTrait::addSimpleCallbackFields in Thunder 6.2.x
Define callback field resolver for a type.
Parameters
string $type: Type to add fields.
array $fields: The fields.
3 calls to ResolverHelperTrait::addSimpleCallbackFields()
- ThunderMetaTagsSchemaExtension::registerResolvers in modules/
thunder_gqls/ src/ Plugin/ GraphQL/ SchemaExtension/ ThunderMetaTagsSchemaExtension.php - ThunderPagesSchemaExtension::resolveFields in modules/
thunder_gqls/ src/ Plugin/ GraphQL/ SchemaExtension/ ThunderPagesSchemaExtension.php - Add article field resolvers.
- ThunderSchema::resolveBaseTypes in modules/
thunder_gqls/ src/ Plugin/ GraphQL/ Schema/ ThunderSchema.php - Resolve custom types, that are used in multiple places.
File
- modules/
thunder_gqls/ src/ Traits/ ResolverHelperTrait.php, line 93
Class
- ResolverHelperTrait
- Helper functions for field resolvers.
Namespace
Drupal\thunder_gqls\TraitsCode
public function addSimpleCallbackFields(string $type, array $fields) {
foreach ($fields as $field) {
$this
->addFieldResolverIfNotExists($type, $field, $this->builder
->callback(function ($arr) use ($field) {
return $arr[$field];
}));
}
}