Skip to content

Commit 1f3d63d

Browse files
committed
Primarily register and use the GraphQL class
Keep the alias for now.
1 parent 969a6f3 commit 1f3d63d

File tree

4 files changed

+11
-5
lines changed

4 files changed

+11
-5
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ CHANGELOG
9494
new: `public function queryAndReturnResult($query, ?array $variables = [], array $opts = []): ExecutionResult`
9595

9696
### Added
97+
- Primarily register \Rebing\GraphQL\GraphQL as service and keep `'graphql'` as alias [\# / mfn]()
9798
- Automatic Persisted Queries (APQ) now cache the parsed query [\#740 / mfn](https://github.com/rebing/graphql-laravel/pull/740)\
9899
This avoids having to re-parse the same queries over and over again.
99100
- Add ability to detect unused GraphQL variables [\#660 / mfn](https://github.com/rebing/graphql-laravel/pull/660)

src/GraphQLController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ protected function executeQuery(string $schemaName, OperationParams $params): ar
5959
: DebugFlag::NONE;
6060

6161
/** @var GraphQL $graphql */
62-
$graphql = Container::getInstance()->make('graphql');
62+
$graphql = Container::getInstance()->make(GraphQL::class);
6363

6464
/** @var Helper $helper */
6565
$helper = Container::getInstance()->make(Helper::class);

src/GraphQLServiceProvider.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ public function register(): void
122122

123123
public function registerGraphQL(): void
124124
{
125-
$this->app->singleton('graphql', function (Container $app): GraphQL {
125+
$this->app->singleton(GraphQL::class, function (Container $app): GraphQL {
126126
$graphql = new GraphQL($app);
127127

128128
$this->applySecurityRules();
@@ -131,8 +131,9 @@ public function registerGraphQL(): void
131131

132132
return $graphql;
133133
});
134+
$this->app->alias(GraphQL::class, 'graphql');
134135

135-
$this->app->afterResolving('graphql', function (GraphQL $graphQL): void {
136+
$this->app->afterResolving(GraphQL::class, function (GraphQL $graphQL): void {
136137
$this->bootTypes($graphQL);
137138
});
138139
}
@@ -162,6 +163,9 @@ public function registerConsole(): void
162163
*/
163164
public function provides()
164165
{
165-
return ['graphql'];
166+
return [
167+
GraphQL::class,
168+
'graphql',
169+
];
166170
}
167171
}

src/Support/Facades/GraphQL.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use GraphQL\Type\Definition\Type;
1010
use GraphQL\Type\Schema;
1111
use Illuminate\Support\Facades\Facade;
12+
use Rebing\GraphQL\GraphQL as RealGraphQL;
1213

1314
/**
1415
* @method static array query(string $query, ?array $params = [], array $opts = [])
@@ -34,6 +35,6 @@ class GraphQL extends Facade
3435
*/
3536
protected static function getFacadeAccessor()
3637
{
37-
return 'graphql';
38+
return RealGraphQL::class;
3839
}
3940
}

0 commit comments

Comments
 (0)