flowctl: add raw graphql commands to introspect and call the GraphQL API - #3352
Draft
GregorShear wants to merge 1 commit into
Draft
flowctl: add raw graphql commands to introspect and call the GraphQL API#3352GregorShear wants to merge 1 commit into
raw graphql commands to introspect and call the GraphQL API#3352GregorShear wants to merge 1 commit into
Conversation
…L API `flowctl raw get` / `rpc` / `update` reach the PostgREST API ad hoc, but the GraphQL API had no equivalent: calling it meant writing a typed `graphql_client` query and rebuilding, and learning its shape meant reading the checked-in SDL or opening GraphiQL in a browser. Add `flowctl raw graphql`, with five subcommands: - `exec` posts a document taken from an argument, `--file`, or stdin, with variables from `--variables` (a JSON object) and repeated `--var name=value` pairs. A `--var` value is used as JSON when it parses as JSON and as a string otherwise, so both `--var first=10` and `--var prefix=acmeCo/` pass what the caller means. The whole response envelope is printed, errors included, and the command exits non-zero when the API reported any — a GraphQL error arrives with an HTTP 200 and would otherwise look like success to a script. - `schema` prints the schema as SDL, or as the raw introspection response for other tooling. - `types` and `operations` list the schema's types and its callable query and mutation fields, filterable by kind, root, and name. - `describe` prints one type's definition, matching case-insensitively and suggesting similar names on a miss. Every command but `exec` reads the schema by introspection, so it describes the API the active profile points at rather than whatever SDL this binary was built against. SDL rendering follows the conventions of the schema that control-plane-api emits into crates/flow-client/control-plane-api.graphql, so the two can be diffed to find where a client's generated types have fallen behind the deployed API. The one departure is that a documented argument list puts each argument on its own line, where async-graphql's own SDL export only breaks before arguments carrying a description and runs the rest together. `exec` and `schema --format introspection` print JSON unless `--output yaml` is given: a GraphQL response has no fixed columns to tabulate, and the usual "YAML when stdout isn't a terminal" default would break pipes into `jq`.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description:
Adds
flowctl raw graphql, the GraphQL counterpart ofraw get/rpc/update:execruns a query or mutation, andschema/types/describe/operationsrender the schema read by introspection.Workflow steps:
Documentation links affected:
None.
crates/flowctl/README.mdgained a usage section.Notes for reviewers:
schemaoutput was diffed againstcrates/flow-client/control-plane-api.graphqlto validate the renderer. It matches, except that a documented argument list gets one argument per line —async_graphql's own SDL export only breaks before arguments carrying a description and runs the rest together.execprints JSON unless-o yaml, so pipes intojqwork. It exits non-zero on GraphQL errors, which arrive with an HTTP 200.--fileand from stdin, and the error path.