Skip to content

feat(cli): let amp query target any Amp server - #28

Open
azf20 wants to merge 1 commit into
mainfrom
feat/cli-query-url
Open

azf20 wants to merge 1 commit into
mainfrom
feat/cli-query-url

Conversation

@azf20

@azf20 azf20 commented Oct 29, 2026

Copy link
Copy Markdown

amp query had http://localhost:1602 hardcoded, so the CLI couldn't query staging or any other remote server. It also exited 1 with no output on any failure.

  • --url / -u falls back to AMP_QUERY_URL, then to http://localhost:1602. It accepts grpc:// and grpc+tls:// (as used by ampd, ampsql and amp-python) as well as http(s)://.
  • --token now falls back to AMP_AUTH_TOKEN, then to the cached login as before.
  • Failures print a reason, e.g. Query failed: [unauthenticated] Jwt is missing or Query failed: [unavailable] connect ECONNREFUSED 127.0.0.1:1602.
  • A root pnpm amp script runs the CLI from source with --experimental-transform-types. The generated protobuf enums need that flag. Building doesn't help, because inside the workspace @edgeandnode/amp still resolves to src/*.ts.
  • The README has a getting-started section: the CLI against staging, and SDK examples for Flight and the Admin API. It notes that @edgeandnode/amp on npm (0.0.55) is the older SDK from edgeandnode/amp.

Not changed: auth.amp.thegraph.com (used by amp auth login) serves an expired certificate, and I couldn't find a replacement host.

Testing

  • pnpm check:tsgo, pnpm lint and pnpm circular pass; pnpm test: 233 passed.
  • Queried staging with flags and with env vars, on Node 24.21 and 22.23. With empty env vars it falls back to the defaults; I checked the Authorization header against a local stub server.
  • Ran the README's TypeScript example against staging, with and without AMP_AUTH_TOKEN.

🤖 Generated with Claude Code

- Add --url (falls back to AMP_QUERY_URL, then http://localhost:1602);
  grpc:// and grpc+tls:// are accepted alongside http(s)://
- Fall back to AMP_AUTH_TOKEN when --token is not passed
- Print why a query failed instead of exiting 1 silently
- Add a `pnpm amp` script and a getting-started README

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

1 participant