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

Add support for array and object encoding #152

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

Conversation

pnwpedro
Copy link
Collaborator

@pnwpedro pnwpedro commented Oct 12, 2023

Ticket(s): BT-4174

Problem

We need to support encoding that allows query composers to pass objects and arrays that include other FQL queries as values.

Solution

Modify encoding to encode to the { "array": .. } and { "object": .. } protocol, and always encode primitives and Fauna special types with { "value": ... }

This implementation treats the "ValueFragment" as more of a "VariableFragment" and leaves how it should be encoded to the encoder.

The outgoing wire protocol in this driver now differs from the incoming protocol. For example, we do not expect to receive { "object: .. } and { "array": .. } from Fauna, but rather the tagged type format Fauna in response.

All queries emitted from this driver will adhere to this protocol.

Out of Scope

Any refactoring to separate tagged typing from wire encoding because it doesn't support timelines for support of this feature.

Testing

  • All unit tests update to test for proper decoding and encoding. Ideally these tests would be more separate and cleaned up.
  • Added integration tests that verify the expected behavior.

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

Copy link

@macmv macmv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there any way to encode query arguments? the @object and @array values still work as-is, and they are the only way to encode query arguments as an object or array.

@@ -24,58 +24,52 @@ class FaunaEncoder:
+-------------------------------+---------------+
Copy link

@macmv macmv Oct 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i can't comment on it, but _RESERVED_TAGS, above this, is no longer used.

@pnwpedro
Copy link
Collaborator Author

pnwpedro commented Oct 16, 2023

is there any way to encode query arguments? the @object and @array values still work as-is, and they are the only way to encode query arguments as an object or array.

Is there a reason to support this? The driver only supports the query interpolation protocol, not a simple query with arguments. Given that, in which scenarios would you use { "@object/@array": ...} over { "object/array": ... }?

Copy link

@macmv macmv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the driver doesn't support the arguments field, then yes you're fine to just use the new object/array format everywhere. The JS driver supports that arguments field, so I was just wondering if we supported that on other drivers too.

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.

6 participants