-
Notifications
You must be signed in to change notification settings - Fork 7
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One small fix to a comment please. Looks good otherwise
TaggedRef, | ||
TaggedBytes, | ||
} from "./wire-protocol"; | ||
import { Query, QueryArgument, QueryArgumentObject } from "./query-builder"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should revisit the type/class organization at some point. We're increasing the strength of our circular dependencies. wire-protocol and tagged-type both now have more dependencies in query-builder, and query-builder already has dependencies in each.
We don't need to address in this PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had some reorganization of types staged but I put everything back. I was worried about
- breaking import paths, and
- complicating the diff for this PR.
On further consideration of no. 1, that doesn't actually matter because we bundle the driver and only expose the exports from src/index and that's it.
So I guess my point is: agreed! We should come back to this.
src/query-builder.ts
Outdated
* A QueryArgument is a plain javascript object where each property is a | ||
* valid QueryArgument. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this comment is correct
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for catching the copy-pasta! I've updated in 7bb285a. How's that?
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.