File tree Expand file tree Collapse file tree 2 files changed +51
-0
lines changed Expand file tree Collapse file tree 2 files changed +51
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types = 1 );
4+ namespace Rebing \GraphQL \Tests \Support \Directives ;
5+
6+ use GraphQL \Language \DirectiveLocation ;
7+ use GraphQL \Type \Definition \Directive ;
8+ use GraphQL \Type \Definition \FieldArgument ;
9+ use GraphQL \Type \Definition \Type ;
10+
11+ class ExampleDirective extends Directive
12+ {
13+ public function __construct ()
14+ {
15+ parent ::__construct ([
16+ 'name ' => 'exampleDirective ' ,
17+ 'description ' => 'This is an example directive ' ,
18+ 'locations ' => [
19+ // See DirectiveLocation constants for all available locations
20+ DirectiveLocation::QUERY ,
21+ ],
22+ 'args ' => [
23+ new FieldArgument ([
24+ 'name ' => 'first ' ,
25+ 'description ' => 'Description of this argument ' ,
26+ 'type ' => Type::string (),
27+ ]),
28+ ],
29+ ]);
30+ }
31+ }
Original file line number Diff line number Diff line change 1515use Rebing \GraphQL \Exception \SchemaNotFound ;
1616use Rebing \GraphQL \Exception \TypeNotFound ;
1717use Rebing \GraphQL \Support \Facades \GraphQL ;
18+ use Rebing \GraphQL \Tests \Support \Directives \ExampleDirective ;
1819use Rebing \GraphQL \Tests \Support \Objects \CustomExampleType ;
1920use Rebing \GraphQL \Tests \Support \Objects \ExamplesQuery ;
2021use Rebing \GraphQL \Tests \Support \Objects \ExampleType ;
@@ -454,6 +455,25 @@ public function testAddSchemaObjectAndExecuteQueryWithRootValue(): void
454455 self ::assertSame ($ expectedResult , $ result );
455456 }
456457
458+ public function testBuildSchemaWithDirectives (): void
459+ {
460+ $ schema = GraphQL::buildSchemaFromConfig ([
461+ 'query ' => [
462+ 'examplesCustom ' => ExamplesQuery::class,
463+ ],
464+ 'directives ' => [
465+ ExampleDirective::class,
466+ ],
467+ ]);
468+
469+ self ::assertSame ([
470+ 'include ' ,
471+ 'skip ' ,
472+ 'deprecated ' ,
473+ 'exampleDirective ' ,
474+ ], array_keys ($ schema ->getDirectives ()));
475+ }
476+
457477 public function testIsMacroable (): void
458478 {
459479 self ::assertContains (Macroable::class, class_uses_recursive (GraphQL::getFacadeRoot ()));
You can’t perform that action at this time.
0 commit comments