diff --git a/src/Folklore/GraphQL/GraphQL.php b/src/Folklore/GraphQL/GraphQL.php index 53cfb98c..b66aec22 100644 --- a/src/Folklore/GraphQL/GraphQL.php +++ b/src/Folklore/GraphQL/GraphQL.php @@ -67,7 +67,7 @@ public function schema($schema = null) $this->typesInstances[$name] = $objectType; $types[] = $objectType; - $this->addType($type, $name); + $this->addType($type, is_numeric($name) ? null : $name); } } else { foreach ($this->types as $name => $type) { diff --git a/tests/GraphQLTest.php b/tests/GraphQLTest.php index 143d6580..4860ccd7 100644 --- a/tests/GraphQLTest.php +++ b/tests/GraphQLTest.php @@ -77,14 +77,21 @@ public function testSchemaWithArray() 'updateExampleCustom' => UpdateExampleMutation::class ], 'types' => [ - CustomExampleType::class + CustomExampleType::class, + AnotherCustomExampleType::class ] ]); - + + $graphql_types = GraphQL::getTypes(); + $schema_types = $schema->getTypeMap(); + $this->assertGraphQLSchema($schema); $this->assertGraphQLSchemaHasQuery($schema, 'examplesCustom'); $this->assertGraphQLSchemaHasMutation($schema, 'updateExampleCustom'); - $this->assertArrayHasKey('CustomExample', $schema->getTypeMap()); + $this->assertArrayHasKey('CustomExample', $schema_types); + $this->assertArrayHasKey('AnotherCustomExample', $schema_types); + $this->assertArrayHasKey('CustomExample', $graphql_types); + $this->assertArrayHasKey('AnotherCustomExample', $graphql_types); } /**