Skip to content

Question about Ref #15

@mbukosky

Description

@mbukosky

Hey,

I have been trying to follow the advanced examples for falcor. I am trying to recreate the "all" route but I am running into odd results. I am not sure if it is a bug with the falcor.net project or my client code. Here is what I have.
Any ideas what I am doing wrong?

In NetflixFalcorRouter

Get["titles[{ranges:indices}]"] = async parameters => {
    List<int> titleIds = parameters.indices;

    var ratings = await ratingService.GetRatingsAsync(titleIds.Select(x => Guid.NewGuid()), userId);
    var results = titleIds.Select(idx => {
        var rating = ratings.ElementAtOrDefault(idx);

        return Path("titles", idx)
            .Ref("titlesById", rating.TitleId.ToString());
    });

    return Complete(results);
};

Client index.html

model.get('titles[0..2]["rating", "userRating"]').then(logJson, logJsonError);

Output

{
   "json": {
      "titles": {
         "0": {
            "\u001epath": [
               "titlesById",
               "aca9317a-d813-4e35-8f22-428652c495c8"
            ],
            "rating": 0,
            "userRating": 0
         },
         "1": {
            "\u001epath": [
               "titlesById",
               "f40b6c24-be45-4969-b541-2f4491d1300a"
            ],
            "rating": 4,
            "userRating": 0
         },
         "2": {
            "\u001epath": [
               "titlesById",
               "656f9ed3-2973-4756-9f82-5d286244dfc7"
            ],
            "rating": 4,
            "userRating": 2
         }
      }
   }
}

To make things more confusing. When looking at the network traffic, I am getting errors. By it resolves somehow? Not really sure.

{
    "jsonGraph": {
        "titles": {
            "0": {
                "$type": "ref",
                "value": [
                    "titlesById",
                    "b697c926-cfd8-4564-8025-7252a3ec4599"
                ]
            },
            "1": {
                "$type": "ref",
                "value": [
                    "titlesById",
                    "7b833be2-ef51-46f4-9de6-77c427b8dce1"
                ]
            },
            "2": {
                "$type": "ref",
                "value": [
                    "titlesById",
                    "e32e733b-f21d-4842-a5f2-a7a21818f6a9"
                ]
            }
        },
        "titlesById": {
            "b697c926-cfd8-4564-8025-7252a3ec4599": {
                "Falcor.KeySet": {
                    "$type": "error",
                    "value": {
                        "message": null
                    }
                }
            },
            "7b833be2-ef51-46f4-9de6-77c427b8dce1": {
                "Falcor.KeySet": {
                    "$type": "error",
                    "value": {
                        "message": null
                    }
                }
            },
            "e32e733b-f21d-4842-a5f2-a7a21818f6a9": {
                "Falcor.KeySet": {
                    "$type": "error",
                    "value": {
                        "message": null
                    }
                }
            }
        }
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions