From 2e82d693f3bb27b1fb93e8d9fbe60635f5198566 Mon Sep 17 00:00:00 2001 From: Jeremiah VALERIE Date: Fri, 26 Jan 2018 19:48:17 +0100 Subject: [PATCH] Remove type resolver postLoad Types are now totally lazy loaded so we can no more rely on type name to resolve it. --- Resolver/AbstractResolver.php | 8 --- Resolver/TypeResolver.php | 10 ---- Resources/doc/definitions/resolver.md | 7 --- .../doc/definitions/type-system/index.md | 50 ++++++++++++++++-- .../GraphQL/HelloWord/Type/MutationType.php | 11 +++- .../App/GraphQL/HelloWord/Type/QueryType.php | 11 +++- UPGRADE-0.11.md | 51 ++++++++++++++++++- 7 files changed, 117 insertions(+), 31 deletions(-) diff --git a/Resolver/AbstractResolver.php b/Resolver/AbstractResolver.php index 0f02652c2..5019c69eb 100644 --- a/Resolver/AbstractResolver.php +++ b/Resolver/AbstractResolver.php @@ -77,7 +77,6 @@ private function loadSolution($name) $loader = $this->solutions[$name]; $this->solutions[$name] = $loader(); $this->fullyLoadedSolutions[$name] = true; - $this->postLoadSolution($this->solutions[$name]); return $this->solutions[$name]; } @@ -95,13 +94,6 @@ private function loadSolutions() return $this->solutions; } - /** - * @param mixed $solution - */ - protected function postLoadSolution($solution) - { - } - /** * @param mixed $solution * diff --git a/Resolver/TypeResolver.php b/Resolver/TypeResolver.php index a8d8c5e40..a85957b0a 100644 --- a/Resolver/TypeResolver.php +++ b/Resolver/TypeResolver.php @@ -113,16 +113,6 @@ private static function createTypeLoadingException($alias, $errorOrException) ); } - protected function postLoadSolution($solution) - { - // also add solution with real type name if needed for typeLoader when using autoMapping - if ($solution && !$this->hasSolution($solution->name)) { - $this->addSolution($solution->name, function () use ($solution) { - return $solution; - }, [], ['id' => get_class($solution), 'alias' => $solution->name]); - } - } - protected function supportedSolutionClass() { return Type::class; diff --git a/Resources/doc/definitions/resolver.md b/Resources/doc/definitions/resolver.md index e17c42835..70a0b6113 100644 --- a/Resources/doc/definitions/resolver.md +++ b/Resources/doc/definitions/resolver.md @@ -123,10 +123,6 @@ Resolvers can be define 2 different ways ```yaml services: - _instanceof: - GraphQL\Type\Definition\Type: - tags: ['overblog_graphql.type'] - App\Mutation\: resource: '../src/Mutation' tags: ['overblog_graphql.mutation'] @@ -134,9 +130,6 @@ Resolvers can be define 2 different ways App\Resolver\: resource: '../src/Resolver' tags: ['overblog_graphql.resolver'] - - App\Type\: - resource: '../src/Type' ``` **Note:** diff --git a/Resources/doc/definitions/type-system/index.md b/Resources/doc/definitions/type-system/index.md index b03f7b7f4..08cd8a7da 100644 --- a/Resources/doc/definitions/type-system/index.md +++ b/Resources/doc/definitions/type-system/index.md @@ -41,9 +41,33 @@ Types can be define 3 different ways: You can also declare PHP types (any subclass of `GraphQL\Type\Definition\Type`) in `src/*Bundle/GraphQL` or `app/GraphQL` they will be auto discover (thanks to auto mapping). Auto map classes are accessible by FQCN - (example: `AppBunble\GraphQL\Type\DateTimeType`), you can also alias type adding - a public static function `getAliases` + (example: `AppBunble\GraphQL\Type\DateTimeType`), you can also alias a type by + implementing `Overblog\GraphQLBundle\Definition\Resolver\AliasedInterface` that returns an array of aliases. + + here an example: + + ```php +