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

Route specificity doesn't match my expecations #125

Closed tivac closed 9 years ago

tivac commented 9 years ago

(see my SO question for the original issue & recommendation that I file a bug)

I've been using falcor to experiment and have found a router behavior I didn't expect. My routes look something like the following:

  1. items[{integers:ids}].name
  2. items[{integers:ids}][{keys:fields}]

No matter the order I declare the routes in if I make a request to the router for items.0.name it'll always be handled by route 2 (the more generic one). It seems like [{keys}] should be lower specificity than a specific field, or even multiple fields. Are the specificity rules laid out somewhere in the docs? I couldn't find them.

Currently I'm getting around this by structuring my routes like this:

Which is super-brittle if new fields become available and also really ugly to write. It also can't be aliased so instead of the really nice pathSet.fields I have to iterate on pathSet[2] which makes for less obvious code.

tivac commented 9 years ago

I've been able to mitigate this now that I understand falcor better by wrapping my objects I need to return as atoms, most of them are small enough that I don't really need specific keys queried out.

This still seems like broken behavior though.

bobvanluijt commented 9 years ago

I'm having the same issue, any updates here?

tivac commented 9 years ago

@michaelbpaulson Awesome, thank you!

bobvanluijt commented 9 years ago

thx