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 b6129e28df..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 @@ -34,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()); + } }