-
Notifications
You must be signed in to change notification settings - Fork 120
Open
Labels
Description
Improvement description
Currently, \Pimcore\Bundle\DataHubBundle\GraphQL\ClassTypeDefinitions::build
is creating type instances for all classes on every request
data-hub/src/GraphQL/ClassTypeDefinitions.php
Lines 35 to 54 in f781127
public static function build(Service $graphQlService, $context = []) | |
{ | |
$db = Db::get(); | |
$listing = $db->fetchAllAssociative('SELECT id, name FROM classes'); | |
foreach ($listing as $class) { | |
$id = $class['id']; | |
$name = $class['name']; | |
$objectType = new PimcoreObjectType($graphQlService, $name, $id, [], $context); | |
self::$definitions[$name] = $objectType; | |
} | |
/** | |
* @var string $name | |
* @var PimcoreObjectType $definition | |
*/ | |
foreach (self::$definitions as $name => $definition) { | |
$definition->build($context); | |
} | |
} |
but not all classes will be used. It would make sense to convert this to a lazy loaded version where the instance is only created when get()
is called.
This build process is almost 40% of the runtime in trivial GraphQL queries.