Invalidate Falcor jsonGraph fragment using jsonGraphEnvelope

84 views Asked by At

I'm trying to invalidate a part of my jsonGraph object via the response from the falcor-router after making a CREATE call. I can successfully do so when returning a list of pathValues, similar to 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];
      });
  })
}

However, when returning the equivalent (afaik) jsonGraphEnvelope, the invalidated path is dropped from the response:

{
  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']]
        };
      });
  })
}

Am I misunderstanding how a jsonGraphEnvelope works (had assumed it was a longhand format equivalent to an array of PathValues)? Or is this likely a bug?

1

There are 1 answers

1
Hugo Wood On BEST ANSWER

Looks like a bug to me.

Invalidations don't seem to be handled in the part of the code responsible for merging partial JSONGraph envelopes returned from routes into the JSONGraph envelope response (see here), while they are handled in the path-value merge (see here).

I can't find any issue about this on GitHub so I invite you to open one.