feat(schema): port schema introspect from Go CLI#11
Draft
beengud wants to merge 2 commits into
Draft
Conversation
Closes #8 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Parameters<introspect>[1] is the deps arg (not [2]); the prior index produced two tsc errors. Caught via typecheck against the published Observe schema setup. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Closes #8
Summary
Ports the
schema introspectcommand from the deprecated Go Observe CLI (cmd_schema.go) into the TypeScript CLI.observe schema introspect [--type <TypeName>]/v1/metaendpoint and prints the result as formatted JSON.--type <TypeName>filters the output to a single named type (e.g.Dashboard,DashboardInput,Mutation,Query), matching against__schema.types[].nameclient-side. Mirrors the Go--typefiltering exactly, including thetype "X" not founderror + non-zero exit.Implementation notes
src/gql/generated/graphql.ts. The introspection query string replicates the exact query the Go CLI used (Schema_Introspect).src/gql/schema/introspect-schema.ts) mirrors the auth/header approach ofexecuteGraphQLinsrc/gql/gql-request.ts(sameAuthorization: Bearer <customerId> <token>header, sameobserveApiHeaders, same/v1/metaURL andGqlApiErrorhandling) but issues the raw query directly since there is noTypedDocumentNodetoprint()..graphqlfile (src/gql/schema/introspect-schema.graphql) is included for parity with the repo convention and is kept in sync with the inline query string.Files added/changed
Added:
src/commands/schema/introspect.tssrc/commands/schema/index.tssrc/commands/schema/introspect.test.tssrc/gql/schema/introspect-schema.tssrc/gql/schema/introspect-schema.graphqlChanged:
src/app.ts— registeredschemaroute (added beforecli, which remains last)README.md— addedobserve schema introspectto the Commands table (order matchessrc/app.ts)AGENTS.md— addedschemaresource to the Project Structure section (commands + gql)Verification status
bun run codegencannot run andsrc/gql/generated/graphql.tsdoes not exist. This is expected; nothing undersrc/gql/generated/was hand-written or committed. Note: this command itself does not import generated types, so it is unaffected by the missing codegen.bun test src/commands/schema/introspect.test.ts-> 5 pass, 0 fail. Covers: full-schema JSON output,--typefiltering to a single type,--typenot-found exit-1, introspection-disabled message + exit-1, and generic API error exit-1. Tests mock the introspection fetch module viamock.module(...)before importing the command, so they run cleanly without codegen.Assumptions / risks
fields,inputFields,enumValues,interfaces,possibleTypes, nestedofTypetwo levels deep,includeDeprecated: true) is copied verbatim from the Go CLI and is standard GraphQL introspection, but could not be validated against a live schema since introspection is disabled.API Errorpath.