File tree 2 files changed +12
-0
lines changed
2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,8 @@ CHANGELOG
3
3
4
4
[ Next release] ( https://github.com/rebing/graphql-laravel/compare/8.3.0...master )
5
5
--------------
6
+ ### Added
7
+ - Register directives via schema config [ \# 946 / sforward] ( https://github.com/rebing/graphql-laravel/pull/946 )
6
8
7
9
2022-06-11, 8.3.0
8
10
-----------------
Original file line number Diff line number Diff line change 10
10
use GraphQL \Error \FormattedError ;
11
11
use GraphQL \Executor \ExecutionResult ;
12
12
use GraphQL \Server \OperationParams as BaseOperationParams ;
13
+ use GraphQL \Type \Definition \Directive ;
13
14
use GraphQL \Type \Definition \ObjectType ;
14
15
use GraphQL \Type \Definition \Type ;
15
16
use GraphQL \Type \Schema ;
@@ -363,6 +364,7 @@ public function buildSchemaFromConfig(array $schemaConfig): Schema
363
364
$ schemaMutation = $ schemaConfig ['mutation ' ] ?? [];
364
365
$ schemaSubscription = $ schemaConfig ['subscription ' ] ?? [];
365
366
$ schemaTypes = $ schemaConfig ['types ' ] ?? [];
367
+ $ schemaDirectives = $ schemaConfig ['directives ' ] ?? [];
366
368
367
369
$ this ->addTypes ($ schemaTypes );
368
370
@@ -378,10 +380,18 @@ public function buildSchemaFromConfig(array $schemaConfig): Schema
378
380
? $ this ->objectType ($ schemaSubscription , ['name ' => 'Subscription ' ])
379
381
: null ;
380
382
383
+ $ directives = Directive::getInternalDirectives ();
384
+
385
+ foreach ($ schemaDirectives as $ class ) {
386
+ $ directive = $ this ->app ->make ($ class );
387
+ $ directives [$ directive ->name ] = $ directive ;
388
+ }
389
+
381
390
return new Schema ([
382
391
'query ' => $ query ,
383
392
'mutation ' => $ mutation ,
384
393
'subscription ' => $ subscription ,
394
+ 'directives ' => $ directives ,
385
395
'types ' => function () {
386
396
$ types = [];
387
397
You can’t perform that action at this time.
0 commit comments