Skip to content

Commit 9cfa27b

Browse files
committed
Update SchemaFactory to allow the annotation cache dir to be configurable
Addresses #309
1 parent 06dc826 commit 9cfa27b

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/SchemaFactory.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ class SchemaFactory
8686
private $parameterMiddlewares = [];
8787
/** @var Reader */
8888
private $doctrineAnnotationReader;
89+
/** @var string */
90+
private $annotationCacheDir;
8991
/** @var AuthenticationServiceInterface|null */
9092
private $authenticationService;
9193
/** @var AuthorizationServiceInterface|null */
@@ -203,6 +205,13 @@ public function setDoctrineAnnotationReader(Reader $annotationReader): self
203205
return $this;
204206
}
205207

208+
public function setAnnotationCacheDir(string $cacheDir): self
209+
{
210+
$this->annotationCacheDir = $cacheDir;
211+
212+
return $this;
213+
}
214+
206215
/**
207216
* Returns a cached Doctrine annotation reader.
208217
* Note: we cannot get the annotation reader service in the container as we are in a compiler pass.
@@ -213,7 +222,8 @@ private function getDoctrineAnnotationReader(): Reader
213222
AnnotationRegistry::registerLoader('class_exists');
214223
$doctrineAnnotationReader = new DoctrineAnnotationReader();
215224

216-
$cache = function_exists('apcu_fetch') ? new ApcuCache() : new PhpFileCache(sys_get_temp_dir() . '/graphqlite.' . crc32(__DIR__));
225+
$cacheDir = $this->annotationCacheDir ?? sys_get_temp_dir();
226+
$cache = function_exists('apcu_fetch') ? new ApcuCache() : new PhpFileCache($cacheDir . '/graphqlite.' . crc32(__DIR__));
217227

218228
$cache->setNamespace($this->cacheNamespace);
219229

0 commit comments

Comments
 (0)