From e501d3a92067b387540bba0a05c2e2d25508072e Mon Sep 17 00:00:00 2001 From: Rudie Dirkx Date: Wed, 30 Apr 2025 22:50:32 +0200 Subject: [PATCH 1/2] remember initial types instead of lazy-loading --- src/Type/Schema.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Type/Schema.php b/src/Type/Schema.php index f01184cae..6e1a418f6 100644 --- a/src/Type/Schema.php +++ b/src/Type/Schema.php @@ -99,6 +99,10 @@ public function __construct($config) $this->extensionASTNodes = $config->extensionASTNodes; $this->config = $config; + + foreach ($this->config->types as $type) { + $this->resolvedTypes[$type->name()] = $type; + } } /** From e6ed1f416fb5eec10e3e07779be96f8a86dcfdb6 Mon Sep 17 00:00:00 2001 From: Rudie Dirkx Date: Fri, 2 May 2025 11:53:44 +0200 Subject: [PATCH 2/2] types callables fix --- src/Type/Schema.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Type/Schema.php b/src/Type/Schema.php index 6e1a418f6..b0332ceaa 100644 --- a/src/Type/Schema.php +++ b/src/Type/Schema.php @@ -100,9 +100,17 @@ public function __construct($config) $this->config = $config; - foreach ($this->config->types as $type) { + $types = $this->config->types; + if (is_callable($types)) { + $types = $types(); + } + foreach ($types as $typeOrLazyType) { + /** @var Type|callable(): Type $typeOrLazyType */ + $type = self::resolveType($typeOrLazyType); + assert($type instanceof NamedType); $this->resolvedTypes[$type->name()] = $type; } + // $this->config->types = []; // Don't resolve these again? } /**