fauna-js icon indicating copy to clipboard operation
fauna-js copied to clipboard

FQL Objects with nested queries

Open Lepozepo opened this issue 2 years ago • 2 comments

It feels like something like this should work with this driver but it currently does not:

const enhancer = { field1: fql`collection.all().paginate(n)` }
query(fql`Object.assign(someDocument, ${enhancer})`)

I'm getting an empty object for field1

Lepozepo avatar Apr 15 '24 17:04 Lepozepo

This seems to be the same behavior with arrays as well, there may be some recursive resolver missing in the tagged template literal

Lepozepo avatar Apr 15 '24 17:04 Lepozepo

Hi @Lepozepo thanks for the feedback! This pattern of query composition is something we want to support and is a work in progress.

We made some changes in the database itself to handle queries-within-literals-within-queries, but there is still some additional work needed to prevent some edge-case query injection issues.

We made these changes in the driver originally here: https://github.com/fauna/fauna-js/pull/214, but reverted it when we identified the issue.

ptpaterson avatar Apr 15 '24 18:04 ptpaterson