Search code examples
falcorfalcor-router

Efficient way to structure falcor router for deep paths?


I'm continuing my experiments with falcor and enjoying most of it, but I'm noticing something concerning.

I'm assembling my JSONGraph from multiple disparate APIs, exactly what falcor-router is intended to do. However I can't seem to find a way to cleanly provide a catch-all for fields that don't need special handling w/o blowing up any routes that do need to do special handling.

My routes look something like the following:

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

No matter the order I declare the routes in the generic one always wins. Is there a better way to avoid this than the full-nuclear option of structuring my routes like this?

  • items[{integers:ids}].name
  • items[{integers:ids}]['fooga', 'wooga', 'booga', 'tooga', ... ]

That seems very brittle, if the data coming from the backing server changes I have to update not only my application code but my router as well. It also becomes a real mess if you have deeply nested objects as the number of permutations climb in a hurry.


Solution

  • I believe this is a bug. The router should match the most specific path first. I would appreciate if you could log it as an issue. We will fix it for you.