Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support users embedding fql snippets in objects and arrays #272

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

ptpaterson
Copy link
Contributor

@ptpaterson ptpaterson commented Jun 12, 2024

Ticket(s): FE-3501

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

  • 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.

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.

@ptpaterson ptpaterson marked this pull request as ready for review June 12, 2024 21:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant