feat(cli): add JSON Schema for hive.json config file#8154
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a JSON Schema (hive-config.schema.json) for the hive.json configuration file, along with corresponding documentation, package updates, and validation tests using ajv. The feedback correctly identifies that the repository name in the schema URLs and $id is incorrectly specified as console instead of platform across several files, including the changeset, README, schema definition, configuration, and test suite.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
|
|
||
| ```json | ||
| { | ||
| "$schema": "https://raw.githubusercontent.com/graphql-hive/console/main/packages/libraries/cli/hive-config.schema.json", |
There was a problem hiding this comment.
The repository name is platform, not console. Update the schema URL to use graphql-hive/platform.
| "$schema": "https://raw.githubusercontent.com/graphql-hive/console/main/packages/libraries/cli/hive-config.schema.json", | |
| "$schema": "https://raw.githubusercontent.com/graphql-hive/platform/main/packages/libraries/cli/hive-config.schema.json", |
|
|
||
| ```json | ||
| { | ||
| "$schema": "https://raw.githubusercontent.com/graphql-hive/console/main/packages/libraries/cli/hive-config.schema.json", |
There was a problem hiding this comment.
The repository name is platform, not console. Update the schema URL to use graphql-hive/platform.
| "$schema": "https://raw.githubusercontent.com/graphql-hive/console/main/packages/libraries/cli/hive-config.schema.json", | |
| "$schema": "https://raw.githubusercontent.com/graphql-hive/platform/main/packages/libraries/cli/hive-config.schema.json", |
| @@ -0,0 +1,94 @@ | |||
| { | |||
| "$schema": "http://json-schema.org/draft-07/schema#", | |||
| "$id": "https://raw.githubusercontent.com/graphql-hive/console/main/packages/libraries/cli/hive-config.schema.json", | |||
There was a problem hiding this comment.
The repository name is platform, not console. Update the $id URL to use graphql-hive/platform.
| "$id": "https://raw.githubusercontent.com/graphql-hive/console/main/packages/libraries/cli/hive-config.schema.json", | |
| "$id": "https://raw.githubusercontent.com/graphql-hive/platform/main/packages/libraries/cli/hive-config.schema.json", |
| @@ -1,4 +1,5 @@ | |||
| { | |||
| "$schema": "https://raw.githubusercontent.com/graphql-hive/console/main/packages/libraries/cli/hive-config.schema.json", | |||
There was a problem hiding this comment.
The repository name is platform, not console. Update the schema URL to use graphql-hive/platform.
| "$schema": "https://raw.githubusercontent.com/graphql-hive/console/main/packages/libraries/cli/hive-config.schema.json", | |
| "$schema": "https://raw.githubusercontent.com/graphql-hive/platform/main/packages/libraries/cli/hive-config.schema.json", |
| const SCHEMA_URL = | ||
| 'https://raw.githubusercontent.com/graphql-hive/console/main/packages/libraries/cli/hive-config.schema.json'; |
There was a problem hiding this comment.
The repository name is platform, not console. Update the SCHEMA_URL to use graphql-hive/platform.
| const SCHEMA_URL = | |
| 'https://raw.githubusercontent.com/graphql-hive/console/main/packages/libraries/cli/hive-config.schema.json'; | |
| const SCHEMA_URL = | |
| 'https://raw.githubusercontent.com/graphql-hive/platform/main/packages/libraries/cli/hive-config.schema.json'; |
ff81e5a to
4d61074
Compare
Background
The Hive CLI reads its settings from a
hive.jsonfile, but there is nomachine-readable description of that file. Editors cannot autocomplete its keys
or flag typos, and an invalid config is only surfaced at runtime as CLI error
100 ("Invalid Config Error").
Issue #3010 asks for a JSON Schema for
hive.json, served over HTTP, so the filecan be referenced via the
$schemaproperty to get autocompletion, inlinedocumentation, and validation while editing.
Description
This change affects the CLI
@graphql-hive/clionly. No services, APIs, or theclient/agent are touched.
packages/libraries/cli/hive-config.schema.json(new): a draft-07 JSON Schema.It is an
anyOfunion of the three shapes theConfigclass actually accepts:registry/cdnobjects withendpoint+accessTokenregistryas a string plustokendefaultkey, or a named space selected byHIVE_SPACE,wrapping either of the above
additionalProperties: falseon the modern and legacy branches gives typodetection (for example
registeryoraccesToken).packages/libraries/cli/package.json: added the schema to thefilesallowlist so it ships with the published package, and added
ajvas adevDependency for the test.
packages/libraries/cli/README.md: documented the$schemaline in the"Config file (
hive.json)" section.packages/libraries/cli/src/helpers/config.ts: a short comment aboveConfigModel/LegacyConfigModelreminding contributors to keep the schemain sync. The schema is hand-written to match the existing
usage-report-v2.schema.jsonprecedent and to avoid azod-to-json-schemadependency.
packages/libraries/cli/hive.json: added a$schemaline to the dev config asa usage example.
.changeset/:@graphql-hive/climinor.Usage
{ "$schema": "https://raw.githubusercontent.com/graphql-hive/console/main/packages/libraries/cli/hive-config.schema.json", "registry": { "endpoint": "https://app.graphql-hive.com/graphql", "accessToken": "..." } }Testing
packages/libraries/cli/tests/hive-config.schema.spec.ts(new): compiles theshipped schema with ajv and runs 13 cases. It accepts all three valid shapes
(each with and without a
$schemaline) plus an empty object, and rejects keytypos and wrong value types.
Configclass and confirmed theschema accepts what the CLI honors for modern and namespaced configs, and that
adding
$schemadoes not break parsing (zod strips the unknown top-level key).Open questions for maintainers
$schemahosting URL: it currently points at the raw GitHubmainfile. Ifyou prefer a stable or branded host (app domain, docs, or a CDN), it is a
one-line change in three places (schema
$id, README example, devhive.json). I can also registerhive.jsonwith SchemaStore as a follow-up.(
{ "registry": "<url>", "token": "..." }) resolve to no endpoint in thecurrent CLI. In
Config.read()the legacy cache is set, thenConfigModel.safeParseruns unconditionally and throws on the stringregistry, and thecatchwipes the cache. This looks like an accidentalregression from
7fafb0774. I keptlegacyConfigin the schema as deprecatedbut intent-correct, and I am happy to fix
read()in this PR or a separate one.HIVE_SPACE/defaultsupport in the schema, ortrim to the documented modern shape only?
hive.json: happy to drop the$schemaline if you would rather nottouch that file.
Checklist