Php SilverStripe GraphQL-查询具有子体的类型时出错

Php SilverStripe GraphQL-查询具有子体的类型时出错,php,graphql,silverstripe,silverstripe-4,Php,Graphql,Silverstripe,Silverstripe 4,我在尝试查询类型和子体时遇到此错误: “片段不能在此处传播,因为类型为\“AppTestObject\”的对象永远不能是类型为\“AppTestChild\” 我使用recipe core、admin、graphql和graphql devtools(都是最新的)设置了一个测试安装,以在基本设置中测试这一点。我创建了两个对象: class TestObject extends DataObject { private static $singular_name = "Test Obje

我在尝试查询类型和子体时遇到此错误:

“片段不能在此处传播,因为类型为\“AppTestObject\”的对象永远不能是类型为\“AppTestChild\”

我使用recipe core、admin、graphql和graphql devtools(都是最新的)设置了一个测试安装,以在基本设置中测试这一点。我创建了两个对象:

class TestObject extends DataObject {

    private static $singular_name = "Test Object";
    private static $plural_name = "Test Objects";
    private static $table_name = "TestObject";

    private static $db = [
        'Title' => 'Varchar(255)'
    ];

}

class TestChild extends DataObject {

    private static $singular_name = "Test Child";
    private static $plural_name = "Test Children";
    private static $table_name = "TestChild";

    private static $db = [
        'Title' => 'Varchar(255)'
    ];

}
并通过配置搭设简易脚手架:

SilverStripe\GraphQL\Controller:
  schema:
    scaffolding:
      types:

        App\TestObject:
          fields: [ID]
          operations:
            read: true

        App\TestChild:
          fields: [ID, Title]
          operations:
            read: true
我能够单独查询这些类型中的每一个,没有任何问题。但是当我试图获取
TestChild
作为
TestObject
的后代时,我得到了上面的错误。以下是我的查询示例:

query {
  readAppTestObjects {
    edges {
      node {
        ...on AppTestChild {
          Title
        }
      }
    }
  }
}
查看graphiql中架构的文档,在引用子体的
readAppTestObjects
下没有任何内容,尽管在silverstripe/graphql的文档中指出:


当读取具有公开子体的类型时(例如,当RedirectorPage也公开时,读取页面),返回类型是基类型和所有公开子体的并集。此联合类型的名称为{BaseType}WithDescents。是的,这是SilverStripe graphql模块中的一个bug。你所做的应该有用


我相信修复正在进行中,您可以在那里跟踪进度。也许可以试试这个补丁并留下一些评论。

Robbie,你真是一颗宝石。这解决了问题。请直接登录GitHub上的pull请求作者;)