diff --git a/src/Scaffolding/Scaffolders/QueryScaffolder.php b/src/Scaffolding/Scaffolders/QueryScaffolder.php index fc0af47c4..96798b9cc 100644 --- a/src/Scaffolding/Scaffolders/QueryScaffolder.php +++ b/src/Scaffolding/Scaffolders/QueryScaffolder.php @@ -85,7 +85,7 @@ public function getTypeName() protected function getType(Manager $manager) { // If an explicit type name has been provided, use it. - $typeName = $this->getTypeName(); + $typeName = parent::getTypeName(); if ($typeName && $manager->hasType($typeName)) { return $manager->getType($typeName); } diff --git a/tests/Scaffolding/Scaffolders/QueryScaffolderTest.php b/tests/Scaffolding/Scaffolders/QueryScaffolderTest.php new file mode 100644 index 000000000..253e89064 --- /dev/null +++ b/tests/Scaffolding/Scaffolders/QueryScaffolderTest.php @@ -0,0 +1,45 @@ +type(FakeRedirectorPage::class); + $scaffolder->addToManager($manager = new Manager()); + $manager->addType(new ObjectType([ + 'name' => 'CustomTypeName', + 'fields' => [ + 'Test' => Type::string(), + ] + ])); + $query = new ItemQueryScaffolder(null, 'CustomTypeName', null, FakePage::class); + $result = $query->scaffold($manager); + $type = $result['type']; + $this->assertInstanceOf(ObjectType::class, $type); + $this->assertEquals('CustomTypeName', $type->config['name']); + + $query = new ItemQueryScaffolder(null, null, null, FakePage::class); + $result = $query->scaffold($manager); + $type = $result['type']; + $this->assertInstanceOf(UnionType::class, $type); + $this->assertEquals( + StaticSchema::inst()->inheritanceTypeNameForDataObject(FakePage::class), + $type->config['name'] + ); + } +}