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
Arguments to be encoded
allow Query within objects and arrays
QueryValue should remain a valid QueryArgument to ensure round-trip-ability
Encoded values sent over the wire
Updated fragment types and remove QueryValue from fragments
Decoded values
Specify QueryValue type only where we decode values from Fauna.
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.
Ticket(s): FE-3501
resolves #259
Problem
Query
instances (i.e. results from thefql
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
andobject
, where the existingfql
fragment can now be nested under thearray
andobject
fragments. Add newencodeInterpolation
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 existingencode
method.Update types to better distinguish between
Query
within objects and arraysQueryValue
should remain a validQueryArgument
to ensure round-trip-abilityQueryValue
from fragmentsQueryValue
type only where we decode values from Fauna.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.