diff --git a/src/Type/Introspection.php b/src/Type/Introspection.php index cf26e0758..32ebef872 100644 --- a/src/Type/Introspection.php +++ b/src/Type/Introspection.php @@ -115,6 +115,7 @@ public static function getIntrospectionQuery(array $options = []): string kind name {$descriptions} + isOneOf fields(includeDeprecated: true) { name {$descriptions} diff --git a/tests/Type/IntrospectionTest.php b/tests/Type/IntrospectionTest.php index be5a17328..b2aa5452a 100644 --- a/tests/Type/IntrospectionTest.php +++ b/tests/Type/IntrospectionTest.php @@ -53,6 +53,7 @@ public function testExecutesAnIntrospectionQuery(): void [ 'kind' => 'OBJECT', 'name' => 'SomeObject', + 'isOneOf' => null, 'fields' => [ [ 'name' => 'someField', @@ -74,6 +75,7 @@ public function testExecutesAnIntrospectionQuery(): void [ 'kind' => 'SCALAR', 'name' => 'String', + 'isOneOf' => null, 'fields' => null, 'inputFields' => null, 'interfaces' => null, @@ -83,6 +85,7 @@ public function testExecutesAnIntrospectionQuery(): void [ 'kind' => 'SCALAR', 'name' => 'Boolean', + 'isOneOf' => null, 'fields' => null, 'inputFields' => null, 'interfaces' => null, @@ -92,6 +95,7 @@ public function testExecutesAnIntrospectionQuery(): void [ 'kind' => 'OBJECT', 'name' => '__Schema', + 'isOneOf' => null, 'fields' => [ 0 => [ 'name' => 'types', @@ -185,6 +189,7 @@ public function testExecutesAnIntrospectionQuery(): void [ 'kind' => 'OBJECT', 'name' => '__Type', + 'isOneOf' => null, 'fields' => [ 0 => [ 'name' => 'kind', @@ -385,6 +390,7 @@ public function testExecutesAnIntrospectionQuery(): void [ 'kind' => 'ENUM', 'name' => '__TypeKind', + 'isOneOf' => null, 'fields' => null, 'inputFields' => null, 'interfaces' => null, @@ -435,6 +441,7 @@ public function testExecutesAnIntrospectionQuery(): void [ 'kind' => 'OBJECT', 'name' => '__Field', + 'isOneOf' => null, 'fields' => [ 0 => [ 'name' => 'name', @@ -547,6 +554,7 @@ public function testExecutesAnIntrospectionQuery(): void [ 'kind' => 'OBJECT', 'name' => '__InputValue', + 'isOneOf' => null, 'fields' => [ 0 => [ 'name' => 'name', @@ -635,6 +643,7 @@ public function testExecutesAnIntrospectionQuery(): void [ 'kind' => 'OBJECT', 'name' => '__EnumValue', + 'isOneOf' => null, 'fields' => [ 0 => [ 'name' => 'name', @@ -697,6 +706,7 @@ public function testExecutesAnIntrospectionQuery(): void [ 'kind' => 'OBJECT', 'name' => '__Directive', + 'isOneOf' => null, 'fields' => [ [ 'name' => 'name', @@ -794,6 +804,7 @@ public function testExecutesAnIntrospectionQuery(): void [ 'kind' => 'ENUM', 'name' => '__DirectiveLocation', + 'isOneOf' => null, 'fields' => null, 'inputFields' => null, 'interfaces' => null, @@ -1831,4 +1842,30 @@ public static function invisibleFieldDataProvider(): iterable yield [fn (): bool => false]; yield [false]; } + + public function testIsOneOf(): void + { + $input = new InputObjectType([ + 'name' => 'SearchInput', + 'isOneOf' => true, + 'fields' => [ + 'name' => ['type' => Type::string()], + 'email' => ['type' => Type::string()], + ], + ]); + + $query = new ObjectType([ + 'name' => 'QueryRoot', + 'fields' => [ + 'input' => ['type' => $input], + ], + ]); + + $schema = new Schema([ + 'query' => $query, + ]); + + $introspection = Introspection::fromSchema($schema); + self::assertTrue($introspection['__schema']['types'][1]['isOneOf']); + } } diff --git a/tests/Validator/QueryComplexityTest.php b/tests/Validator/QueryComplexityTest.php index 8ea6da018..57269c357 100644 --- a/tests/Validator/QueryComplexityTest.php +++ b/tests/Validator/QueryComplexityTest.php @@ -164,7 +164,7 @@ public function testQueryWithCustomAndSkipDirective(): void public function testComplexityIntrospectionQuery(): void { - $this->assertIntrospectionQuery(187); + $this->assertIntrospectionQuery(188); } public function testIntrospectionTypeMetaFieldQuery(): void