使用jsonGraphEnvelope使Falcor jsonGraph片段无效

时间:2016-10-02 22:51:29

标签: falcor falcor-router

我正在尝试在进行CREATE调用后通过来自falcor-router的响应使我的jsonGraph对象的一部分无效。我可以在返回pathValues列表时成功执行此操作,类似于this earlier SE question

{
  route: 'foldersById[{keys:ids}].folders.createSubFolder',
  call(callPath, args, refPaths, thisPaths) {
    return createNewFolderSomehow(...)
      .subscribe(folder => {
        const folderPathValue = {
          path: ['foldersById', folder.parentId, 'folders', folder.parentSubFolderCount -1],
          value: $ref(['foldersById', folder.id])
        };

        const folderCollectionLengthPathValue = {
          path: ['folderList', 'length'],
          invalidated: true
        };

        return [folderPathValue, folderCollectionLengthPathValue];
      });
  })
}

但是,当返回等效值(afaik)jsonGraphEnvelope时,将从响应中删除无效路径:

{
  route: 'foldersById[{keys:ids}].folders.createSubFolder',
  call(callPath, args, refPaths, thisPaths) {
    return createNewFolderSomehow(...)
      .subscribe(folder => {
        const newFolderPath = ['foldersById', folder.parentId, 'folders', folder.parentSubFolderCount -1];
        return {
          jsonGraph: R.assocPath(folderPath, $ref(['foldersById', folder.id]), {})
          paths: [newFolderPath],
          invalidated: [['folderList', 'length']]
        };
      });
  })
}

我是否误解了jsonGraphEnvelope的工作原理(假设它是一个等同于PathValues数组的简写格式)?或者这可能是一个错误?

1 个答案:

答案 0 :(得分:1)

对我来说看起来像个错误。

在负责将从路由返回的部分JSONGraph包络合并到JSONGraph包络响应(参见here)的代码部分中似乎没有处理失效,而它们是在路径值合并中处理的(见here)。

我在GitHub上找不到任何关于此的问题,所以我邀请您打开一个。