Skip to content

Conversation

yuchenshi
Copy link
Member

@yuchenshi yuchenshi commented Oct 7, 2025

Description

This adds a new command to execute Data Connect operations.

Scenarios Tested

image

See Sample Commands below for more.

Sample Commands

firebase dataconnect:execute MyOperation
# REMOVED for now: firebase dataconnect:execute my-connector MyOperation
firebase dataconnect:execute ./my-file.gql
firebase dataconnect:execute ./my-file.gql MyOperation

Created using spr 1.3.6-beta.1
Created using spr 1.3.6-beta.1
});
}

// Log the body to stdout to allow pipe processing (even with .errors).
Copy link
Member Author

Choose a reason for hiding this comment

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

This doesn't work quite nicely since errors thrown (below, if any) are also logged to stdout (globally handled). Piping to jq for example can choke on the extra output

} else {
if (fileOrConnector === "-") {
stdinUsedFor = "operation source code";
if (process.stdin.isTTY) {
Copy link
Member Author

Choose a reason for hiding this comment

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

As discussed internally, I tried to throw an error if options.nonInteractive but that creates a false positive when --json is passed, since --json right now implies options.nonInteractive (handled globally).

I don't think erroring on --json matches user intention, so I left that part out.

@fredzqm
Copy link
Contributor

fredzqm commented Oct 12, 2025

Can you limit the scope of this PR to a minimum set of API that has no ongoing debates? Probably will make it easier to make progress and unblock the primary seed data CUJ in quick start.

# Yes, please!
firebase dataconnect:execute ./my-file.gql

# Let's defer.
# The tests CreatePlayer example made me nervous. tests appear like the folder name for someone new to FDC.
firebase dataconnect:execute my-connector MyOperation

# Prefer to defer it. Though won't block on it.
# There is less ambiguity between file and operation name, we can detect based on convention.
# Though the alternative `-n MyOperation` is simple, unambitious. It also allows taking multiple files. Multi seed file is a super common use case.
firebase dataconnect:execute MyOperation
firebase dataconnect:execute ./my-file.gql MyOperation

Created using spr 1.3.6-beta.1
@yuchenshi
Copy link
Member Author

Removed connector and --impersonate. Keeping operation name as a positional argument per offline discussion

@yuchenshi yuchenshi marked this pull request as ready for review October 13, 2025 22:39
Created using spr 1.3.6-beta.1
@yuchenshi yuchenshi enabled auto-merge (squash) October 13, 2025 22:41
@joehan
Copy link
Contributor

joehan commented Oct 13, 2025

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This PR introduces a new firebase dataconnect:execute command, which is a great addition for developers working with Data Connect. The implementation is comprehensive, covering various ways to specify queries and variables, including from files and stdin, which improves usability.

I've left a couple of suggestions to improve error handling in JSON parsing functions. Making error messages more precise will help users debug their inputs more effectively.

Overall, this is a solid contribution that enhances the Data Connect developer experience.

Created using spr 1.3.6-beta.1
Copy link
Contributor

@joehan joehan left a comment

Choose a reason for hiding this comment

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

Some small things and a general concern about the deeply nested code. If feasible, it would be great to simplify a bit, but if not, I won't block on it.

return source.files[0].content;
}
let query = "";
for (const f of source.files) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Highly tempted to do this with functional programming as .filter(...).map(...).reduce(...), but this probably reads cleaner as is.

Created using spr 1.3.6-beta.1
Created using spr 1.3.6-beta.1
@yuchenshi yuchenshi merged commit 247c718 into master Oct 14, 2025
48 checks passed
@yuchenshi yuchenshi deleted the spr/yuchenshi/implement-dataconnectexecute-command branch October 14, 2025 17:17
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.

3 participants