是否有可能摆脱 'data' ,'nodes', ... 字段?

Opl*_*pl0 3 graphql postgraphile

我有以下 GraphQL 查询:

{
  allForums {
    nodes {
      name,
      topics: topicsByForumId(orderBy: [TITLE_ASC]) {
        nodes {
          title
        }
      }
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

这将返回如下内容:

{
  "data": {
    "allForums": {
      "nodes": [
        {
          "name": "1",
          "topics": {
            "nodes": [
              {
                "title": "a"
              },
              {
                "title": "b"
              }
            ]
          }
        }
      ]
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

我想得到以下结果:

[
    {
        "name": "1",
        "topics": [
            {
                "title": "a"
            },
            {
                "title", "b"
            }
        ]
    }
]
Run Code Online (Sandbox Code Playgroud)

是否有可能摆脱data, nodes, ... 字段?这是可以在 GraphQL 中完成的事情,还是应该在我的服务实现中完成?

我在 PostgreSQL v11 之上使用 PostGraphile v4.2.0 作为 GraphQL 实现。

Dan*_*den 5

文档所述,您可以公开一个更简单的连接接口,或者完全消除默认的基于 Relay 的连接接口:

如果您更喜欢 GraphQL 连接上更简单的列表界面,那么您可以使用我们的 --simple-collections [omit|both|only] 选项与我们的连接(两者)一起或专门(仅)启用它。