Skip to content

Commit

Permalink
Verify that a type name is specified before overriding class's type name
Browse files Browse the repository at this point in the history
  • Loading branch information
sburba committed Aug 1, 2018
1 parent 171631a commit 09b73ef
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Folklore/GraphQL/GraphQL.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
13 changes: 10 additions & 3 deletions tests/GraphQLTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down

0 comments on commit 09b73ef

Please sign in to comment.