Graphql 中继数组字段

Graphql relay array field

我开始为来自 Apollo 的中继开发。 我在 SQLITE3 数据库上有一个哑服务器 运行 只是为了在重构时进行测试。 在后端使用 graphql-relay

目前我有这样的东西:

{
  root: {
    allFoo: [FooType]
  } 
}

我想知道如何将新的 FooType 项添加到 allFoo 列表中。 在 getConfigs the RANGE_ADD 上仅作用于连接。 那么我是否需要让我的 allFoo 类型成为连接而不是 GraphqlList(FooType) ?或者我能以某种方式使用 FIELD_CHANGE 吗?

看看这个例子: https://github.com/bfwg/relay-gallery/blob/master/frontend/src/app/mutation/AddImageMutation.js#L47

下面的示例演示了如何将图片添加到图片列表中。

getConfigs() {
  return [{
    type: 'RANGE_ADD',
    parentName: 'User',
    parentID: this.props.images.id,
    connectionName: 'images',
    edgeName: 'newImageEdge',
    rangeBehaviors: {
      '': 'prepend',
    },
  }];
}

希望对您有所帮助!