Caching Metadata

The process of attributing your entities results in an array of metadata that is used internal to this library. If you have a very large number of attributed entities it may be faster to cache your metadata instead of rebuilding it with each request.

 1<?php
 2
 3use ApiSkeletons\Doctrine\GraphQL\Driver;
 4use ApiSkeletons\Doctrine\GraphQL\Metadata;
 5
 6$metadata = $cache->get('GraphQLMetadata');
 7
 8if (! $metadata) {
 9    $driver = new Driver($entityManager);
10
11    $metadata = $driver->get('metadata');
12    $cache->set('GraphQLMetadata', $metadataConfig->getArrayCopy());
13} else {
14    // The second parameter is the Config object
15    $driver = new Driver($entityManager, null, $metadata);
16}

This is documentation for API-Skeletons/doctrine-graphql. Please add your ★ star to the project.

Authored by API Skeletons.