From 8e0783ef6420779a421e4ca77df57ca69dfef505 Mon Sep 17 00:00:00 2001 From: Ryan Mitchell Date: Wed, 18 Jun 2025 15:33:35 +0100 Subject: [PATCH 1/2] Ensure nav blueprint graphql types are registered --- src/GraphQL/Types/NavPageInterface.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/GraphQL/Types/NavPageInterface.php b/src/GraphQL/Types/NavPageInterface.php index b6129e28df..a6d20fa1ef 100644 --- a/src/GraphQL/Types/NavPageInterface.php +++ b/src/GraphQL/Types/NavPageInterface.php @@ -19,6 +19,8 @@ public function __construct(Nav $nav) public function fields(): array { + $this->nav->blueprint()->addGqlTypes(); + if ($fields = $this->nav->blueprint()->fields()->toGql()->all()) { return $fields; } From b82cece02cc2d38887cfabd50bd6f747e84b8bc4 Mon Sep 17 00:00:00 2001 From: Ryan Mitchell Date: Thu, 19 Jun 2025 15:18:46 +0100 Subject: [PATCH 2/2] Change approach --- src/GraphQL/TypeRegistrar.php | 2 ++ src/GraphQL/Types/NavPageInterface.php | 10 ++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/GraphQL/TypeRegistrar.php b/src/GraphQL/TypeRegistrar.php index 9bebf1df91..30936cc983 100644 --- a/src/GraphQL/TypeRegistrar.php +++ b/src/GraphQL/TypeRegistrar.php @@ -17,6 +17,7 @@ use Statamic\GraphQL\Types\GlobalSetInterface; use Statamic\GraphQL\Types\JsonArgument; use Statamic\GraphQL\Types\LabeledValueType; +use Statamic\GraphQL\Types\NavPageInterface; use Statamic\GraphQL\Types\NavTreeBranchType; use Statamic\GraphQL\Types\NavType; use Statamic\GraphQL\Types\PageInterface; @@ -71,6 +72,7 @@ public function register() AssetInterface::addTypes(); GlobalSetInterface::addTypes(); UserType::addTypes(); + NavPageInterface::addTypes(); $this->registered = true; } diff --git a/src/GraphQL/Types/NavPageInterface.php b/src/GraphQL/Types/NavPageInterface.php index a6d20fa1ef..b542fd61b1 100644 --- a/src/GraphQL/Types/NavPageInterface.php +++ b/src/GraphQL/Types/NavPageInterface.php @@ -5,6 +5,7 @@ use Rebing\GraphQL\Support\InterfaceType; use Statamic\Contracts\Structures\Nav; use Statamic\Facades\GraphQL; +use Statamic\Facades\Nav as NavAPI; use Statamic\Support\Str; class NavPageInterface extends InterfaceType @@ -19,8 +20,6 @@ public function __construct(Nav $nav) public function fields(): array { - $this->nav->blueprint()->addGqlTypes(); - if ($fields = $this->nav->blueprint()->fields()->toGql()->all()) { return $fields; } @@ -36,4 +35,11 @@ public static function buildName(Nav $nav): string { return 'NavPage_'.Str::studly($nav->handle()); } + + public static function addTypes() + { + GraphQL::addTypes(NavAPI::all()->each(function ($nav) { + optional($nav->blueprint())->addGqlTypes(); + })->mapInto(NavBasicPageType::class)->all()); + } }