Skip to content

Commit 123e367

Browse files
ruudkspawnia
authored andcommitted
Add missing isOneOf to Introspection query
When using `Introspection::fromSchema($schema)` you should also get the `isOneOf` values.
1 parent 1c3e77c commit 123e367

File tree

3 files changed

+39
-1
lines changed

3 files changed

+39
-1
lines changed

src/Type/Introspection.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ public static function getIntrospectionQuery(array $options = []): string
115115
kind
116116
name
117117
{$descriptions}
118+
isOneOf
118119
fields(includeDeprecated: true) {
119120
name
120121
{$descriptions}

tests/Type/IntrospectionTest.php

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ public function testExecutesAnIntrospectionQuery(): void
5353
[
5454
'kind' => 'OBJECT',
5555
'name' => 'SomeObject',
56+
'isOneOf' => null,
5657
'fields' => [
5758
[
5859
'name' => 'someField',
@@ -74,6 +75,7 @@ public function testExecutesAnIntrospectionQuery(): void
7475
[
7576
'kind' => 'SCALAR',
7677
'name' => 'String',
78+
'isOneOf' => null,
7779
'fields' => null,
7880
'inputFields' => null,
7981
'interfaces' => null,
@@ -83,6 +85,7 @@ public function testExecutesAnIntrospectionQuery(): void
8385
[
8486
'kind' => 'SCALAR',
8587
'name' => 'Boolean',
88+
'isOneOf' => null,
8689
'fields' => null,
8790
'inputFields' => null,
8891
'interfaces' => null,
@@ -92,6 +95,7 @@ public function testExecutesAnIntrospectionQuery(): void
9295
[
9396
'kind' => 'OBJECT',
9497
'name' => '__Schema',
98+
'isOneOf' => null,
9599
'fields' => [
96100
0 => [
97101
'name' => 'types',
@@ -185,6 +189,7 @@ public function testExecutesAnIntrospectionQuery(): void
185189
[
186190
'kind' => 'OBJECT',
187191
'name' => '__Type',
192+
'isOneOf' => null,
188193
'fields' => [
189194
0 => [
190195
'name' => 'kind',
@@ -385,6 +390,7 @@ public function testExecutesAnIntrospectionQuery(): void
385390
[
386391
'kind' => 'ENUM',
387392
'name' => '__TypeKind',
393+
'isOneOf' => null,
388394
'fields' => null,
389395
'inputFields' => null,
390396
'interfaces' => null,
@@ -435,6 +441,7 @@ public function testExecutesAnIntrospectionQuery(): void
435441
[
436442
'kind' => 'OBJECT',
437443
'name' => '__Field',
444+
'isOneOf' => null,
438445
'fields' => [
439446
0 => [
440447
'name' => 'name',
@@ -547,6 +554,7 @@ public function testExecutesAnIntrospectionQuery(): void
547554
[
548555
'kind' => 'OBJECT',
549556
'name' => '__InputValue',
557+
'isOneOf' => null,
550558
'fields' => [
551559
0 => [
552560
'name' => 'name',
@@ -635,6 +643,7 @@ public function testExecutesAnIntrospectionQuery(): void
635643
[
636644
'kind' => 'OBJECT',
637645
'name' => '__EnumValue',
646+
'isOneOf' => null,
638647
'fields' => [
639648
0 => [
640649
'name' => 'name',
@@ -697,6 +706,7 @@ public function testExecutesAnIntrospectionQuery(): void
697706
[
698707
'kind' => 'OBJECT',
699708
'name' => '__Directive',
709+
'isOneOf' => null,
700710
'fields' => [
701711
[
702712
'name' => 'name',
@@ -794,6 +804,7 @@ public function testExecutesAnIntrospectionQuery(): void
794804
[
795805
'kind' => 'ENUM',
796806
'name' => '__DirectiveLocation',
807+
'isOneOf' => null,
797808
'fields' => null,
798809
'inputFields' => null,
799810
'interfaces' => null,
@@ -1831,4 +1842,30 @@ public static function invisibleFieldDataProvider(): iterable
18311842
yield [fn (): bool => false];
18321843
yield [false];
18331844
}
1845+
1846+
public function testIsOneOf(): void
1847+
{
1848+
$input = new InputObjectType([
1849+
'name' => 'SearchInput',
1850+
'isOneOf' => true,
1851+
'fields' => [
1852+
'name' => ['type' => Type::string()],
1853+
'email' => ['type' => Type::string()],
1854+
],
1855+
]);
1856+
1857+
$query = new ObjectType([
1858+
'name' => 'QueryRoot',
1859+
'fields' => [
1860+
'input' => ['type' => $input],
1861+
],
1862+
]);
1863+
1864+
$schema = new Schema([
1865+
'query' => $query,
1866+
]);
1867+
1868+
$introspection = Introspection::fromSchema($schema);
1869+
self::assertTrue($introspection['__schema']['types'][1]['isOneOf']);
1870+
}
18341871
}

tests/Validator/QueryComplexityTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ public function testQueryWithCustomAndSkipDirective(): void
164164

165165
public function testComplexityIntrospectionQuery(): void
166166
{
167-
$this->assertIntrospectionQuery(187);
167+
$this->assertIntrospectionQuery(188);
168168
}
169169

170170
public function testIntrospectionTypeMetaFieldQuery(): void

0 commit comments

Comments
 (0)