Skip to content

Commit 84272b8

Browse files
committed
- add test for extension nodes
1 parent d524cb9 commit 84272b8

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

tests/Utils/BuildSchemaTest.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1042,6 +1042,39 @@ public function testCorrectlyExtendInputObjectType(): void
10421042
self::assertSame($inputSDL, $this->printAllASTNodes($someInput));
10431043
}
10441044

1045+
/** @see it('Correctly extend input object type with @oneOf directive') */
1046+
public function testCorrectlyExtendInputObjectTypeWithOneOfDirective(): void
1047+
{
1048+
$inputSDL = <<<'GRAPHQL'
1049+
input SomeInput {
1050+
first: String
1051+
}
1052+
1053+
extend input SomeInput @oneOf {
1054+
second: Int
1055+
}
1056+
1057+
GRAPHQL;
1058+
1059+
$schema = BuildSchema::build($inputSDL);
1060+
1061+
$someInput = $schema->getType('SomeInput');
1062+
assert($someInput instanceof InputObjectType);
1063+
1064+
// Verify that the @oneOf directive from the extension is properly applied
1065+
self::assertTrue($someInput->isOneOf());
1066+
1067+
$expectedSomeInputSDL = <<<'GRAPHQL'
1068+
input SomeInput @oneOf {
1069+
first: String
1070+
second: Int
1071+
}
1072+
GRAPHQL;
1073+
1074+
self::assertSame($expectedSomeInputSDL, SchemaPrinter::printType($someInput));
1075+
self::assertSame($inputSDL, $this->printAllASTNodes($someInput));
1076+
}
1077+
10451078
/** @see it('Correctly assign AST nodes') */
10461079
public function testCorrectlyAssignASTNodes(): void
10471080
{

0 commit comments

Comments
 (0)