FQL functions chaining

I have been digging into the FaunaDB docs and trying to get a grasp on FQL as I proceed. I really resonate with the team’s views of how they want the FaunaDB constructs to be as close to programming language constructs as possible.

One particular area which I struggle with while trying to understand FQL query examples are how any slightly complicated queries are nested. It would be highly helpful if FQL functions could also be chained like methods in other programming languages. So, the way I imagine it would work is every operation returns the data after it is done processing and then the next FQL function would be passed its result and the final data returned is from the last FQL function that runs.

This kind of flow would be a lot easier to read and reason about.

I understand if the above is not feasible due to technical reasons but it would really boost the readability of FQL queries.

Hi @Saikat_Das and welcome,

Would you drop an example? You can probably do that with nested Let(), but I’m happy give you a more clear answer if you elaborate a bit.

Luigi

Hey @Saikat_Das, I currently have a FQL wrapper in the works where I use chaining. I plan to open source this at some point in the near future (famous last words…). So a very simple example would be: q.Chain([1,2,3]).Add() => 6
So with something like Map(Filter(Map(Paginate(…), …), …), …) the Chain approach will be much more readable. Are you using JavaScript?