Netflix / falcor-router

A Falcor JavaScript DataSource which creates a Virtual JSON Graph document on your app server.
http://netflix.github.io/falcor
Apache License 2.0
104 stars 46 forks source link

Router fails to complete all routes for path set containing array in root node #220

Closed eternalmatt closed 6 years ago

eternalmatt commented 6 years ago

I apologize if I'm not using the right terminology , but here is the bug in the form of a Jasmine test

var router = require('falcor-router');

it('should not bomb', function (done) {

    function identityPath() {
        return function (pathSet) {
            return {
                path: pathSet,
                value: JSON.stringify(pathSet)
            };
        };
    }

    var instance = new router([{
        route: 'brother["name"]',
        get: identityPath()
    }, {
        route: 'brother["age"]',
        get: identityPath()
    }, {
        route: 'sister["name"]',
        get: identityPath()
    }, {
        route: 'sister["age"]',
        get: identityPath()
    }]);

    instance.get([
        [ ['brother','sister'], ['age', 'name'] ]
    ]).subscribe(function (data) {

        expect(data.jsonGraph.brother).toBeDefined();
        expect(data.jsonGraph.brother).toEqual({age: '["brother","age"]', name: '["brother","name"]'});

        expect(data.jsonGraph.sister).toBeDefined();
        expect(data.jsonGraph.sister).toEqual({age: '["sister","age"]', name: '["sister","name"]'});
        done();

    }, done.fail);

});

Expected Object({ age: Object({ $type: 'atom' }), name: Object({ $type: 'atom' }) }) to equal Object({ age: '["brother","age"]', name: '["brother","name"]' }).

falcor-router is fulfilling the routes for 'sister', but is somehow forgetting about the routes for 'brother'. You can change the initial pathset to [ ['brother'], ['age','name'] ] (or sister), and falcor will fulfill the subset without issue. Likewise, you can request [ ['brother','sister'], ['age'] ] and there is no issue.

I'm not stating the above as a workaround; rather, I'm just showing that my test case issue is valid.

eternalmatt commented 6 years ago

This issue seems to have been resolved somewhere between 0.4.0 and 0.8.1