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

FE-6299 Implement FQL formatting for v4 queries #559

Merged
merged 8 commits into from
Jan 15, 2025

Conversation

ptpaterson
Copy link
Contributor

@ptpaterson ptpaterson commented Jan 13, 2025

Problem

We are defaulting all queries to JSON, which prints the wire protocol. v10 queries print the FQL format by default.

Other work while here

Some valid FQL expressions are recognized as executable javascript, including objects and any falsy values like null and false, so they are either treated strangely or rejected as queries.

Solution

Output FQL formatting for v4 queries using util.inspect().

Colorize the output using the FQL grammar.

wrap query expressions in an IIFE so that simple values can be provided as queries.

Result

image

image

Testing

Added tests to verify formatting and ability to query simple values.

@ptpaterson ptpaterson requested a review from a team as a code owner January 13, 2025 22:22
Copy link
Contributor

@ecooper ecooper left a comment

Choose a reason for hiding this comment

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

Some nits, but otherwise LGTM. Thanks for fixing this.

src/lib/formatting/codeToAnsi.mjs Outdated Show resolved Hide resolved
src/lib/faunadb.mjs Show resolved Hide resolved
@ptpaterson ptpaterson requested review from echo-bravo-yahoo and a team January 14, 2025 13:47
@ptpaterson ptpaterson merged commit fdc2f3d into main Jan 15, 2025
4 checks passed
@ptpaterson ptpaterson deleted the fe-6299-v4-formatting branch January 15, 2025 22:05
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.

4 participants