Skip to content

Commit d60dea8

Browse files
committed
INTERFACE support.
1 parent 51e8126 commit d60dea8

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

src/Utils/SchemaPrinter.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,7 @@ protected static function printInterface(InterfaceType $type, array $options): s
404404
return static::printDescription($options, $type) .
405405
sprintf('interface %s', $type->name) .
406406
self::printImplementedInterfaces($type) .
407+
static::printTypeDirectives($type, $options) .
407408
static::printFields($options, $type);
408409
}
409410

@@ -491,7 +492,7 @@ protected static function printBlock(array $items): string
491492
}
492493

493494
/**
494-
* @param Type|EnumValueDefinition|EnumType $type
495+
* @param Type|EnumValueDefinition|EnumType|InterfaceType $type
495496
* @param array<string, bool> $options
496497
* @phpstan-param Options $options
497498
*/
@@ -510,7 +511,7 @@ protected static function printTypeDirectives($type, array $options, string $ind
510511
// AST Node available and has directives?
511512
$node = $type->astNode;
512513

513-
if (!($node instanceof ScalarTypeDefinitionNode || $node instanceof EnumValueDefinitionNode || $node instanceof EnumTypeDefinitionNode)) {
514+
if (!$node) {
514515
return '';
515516
}
516517

tests/Utils/SchemaPrinterTest.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1309,6 +1309,14 @@ enum EnumA @test {
13091309
enum EnumB @test(value: "{$text}") {
13101310
a
13111311
}
1312+
1313+
interface InterfaceA @test {
1314+
a: ID
1315+
}
1316+
1317+
interface InterfaceB @test(value: "{$text}") {
1318+
a: ID
1319+
}
13121320
GRAPHQL;
13131321
$expected = /** @lang GraphQL */ <<<'GRAPHQL'
13141322
directive @test(value: String) on SCHEMA | SCALAR | OBJECT | FIELD_DEFINITION | ARGUMENT_DEFINITION | INTERFACE | UNION | ENUM | ENUM_VALUE | INPUT_OBJECT | INPUT_FIELD_DEFINITION
@@ -1337,6 +1345,15 @@ enum EnumB
13371345
a
13381346
}
13391347
1348+
interface InterfaceA @test {
1349+
a: ID
1350+
}
1351+
1352+
interface InterfaceB
1353+
@test(value: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") {
1354+
a: ID
1355+
}
1356+
13401357
scalar ScalarA @test
13411358
13421359
scalar ScalarB

0 commit comments

Comments
 (0)