fauna / fauna-js

Javascript driver for Fauna v10 (current)
https://fauna.com
Other
37 stars 7 forks source link

Support users embedding fql snippets in objects and arrays #272

Closed ptpaterson closed 5 months ago

ptpaterson commented 5 months ago

Ticket(s): FE-3501

resolves #259

Problem

Query instances (i.e. results from the fql function) cannot be encoded when embedded in objects or arrays.

The QueryValue type is incorrectly used for types over the wire.

Solution

The database now accepts a query interpolation fragments for array and object, where the existing fql fragment can now be nested under the array and object fragments. Add new encodeInterpolation method to encode with the new fragments.

Query arguments do not use interpolation, so they still need the @object tag. Encoding arguments still uses the existing encode method.

Update types to better distinguish between

Result

Queries can be encoded in QueryInterpolations.

Queries can be embedded within JS arrays and objects.

Type changes are corrections to the internal implementation. No user-facing changes were made to types (except QueryArgument)

Out of scope

n/a

Testing

Updated existing tests and added new ones for embedding queries in arrays and objects.


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.