Skip to content

Commit 09b73ef

Browse files
author
sburba
committed
Verify that a type name is specified before overriding class's type name
Fixes folkloreinc#365
1 parent 171631a commit 09b73ef

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

src/Folklore/GraphQL/GraphQL.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public function schema($schema = null)
6767
$this->typesInstances[$name] = $objectType;
6868
$types[] = $objectType;
6969

70-
$this->addType($type, $name);
70+
$this->addType($type, is_numeric($name) ? null : $name);
7171
}
7272
} else {
7373
foreach ($this->types as $name => $type) {

tests/GraphQLTest.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,21 @@ public function testSchemaWithArray()
7777
'updateExampleCustom' => UpdateExampleMutation::class
7878
],
7979
'types' => [
80-
CustomExampleType::class
80+
CustomExampleType::class,
81+
AnotherCustomExampleType::class
8182
]
8283
]);
83-
84+
85+
$graphql_types = GraphQL::getTypes();
86+
$schema_types = $schema->getTypeMap();
87+
8488
$this->assertGraphQLSchema($schema);
8589
$this->assertGraphQLSchemaHasQuery($schema, 'examplesCustom');
8690
$this->assertGraphQLSchemaHasMutation($schema, 'updateExampleCustom');
87-
$this->assertArrayHasKey('CustomExample', $schema->getTypeMap());
91+
$this->assertArrayHasKey('CustomExample', $schema_types);
92+
$this->assertArrayHasKey('AnotherCustomExample', $schema_types);
93+
$this->assertArrayHasKey('CustomExample', $graphql_types);
94+
$this->assertArrayHasKey('AnotherCustomExample', $graphql_types);
8895
}
8996

9097
/**

0 commit comments

Comments
 (0)