-
Notifications
You must be signed in to change notification settings - Fork 25
Hive Console plugin for Gateway and introduce new target option #809
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+258
−96
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
8b3ed16
useHiveConsole
enisdenjo 76a313c
hive usage reporting target
enisdenjo 9238c6b
hive usage in cli
enisdenjo 434b01e
subgraph
enisdenjo 71b444b
handle reporting config considers the config
enisdenjo 8eea924
pass through reporting
enisdenjo 01a805a
no or
enisdenjo 4d89a01
enable and spread no undefined
enisdenjo 4bbc4b4
leave disabled
enisdenjo b09cad7
chore(dependencies): updated changesets for modified dependencies
github-actions[bot] 2e32657
changesets
enisdenjo 9bf72e0
minor bigman
enisdenjo bf89e90
use hive console debug mode
enisdenjo 3aa59ad
changeset
enisdenjo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
'@graphql-hive/gateway-runtime': patch | ||
--- | ||
|
||
dependencies updates: | ||
|
||
- Added dependency [`@graphql-hive/yoga@^0.41.0` ↗︎](https://www.npmjs.com/package/@graphql-hive/yoga/v/0.41.0) (to `dependencies`) | ||
- Removed dependency [`@graphql-mesh/plugin-hive@^0.104.0` ↗︎](https://www.npmjs.com/package/@graphql-mesh/plugin-hive/v/0.104.0) (from `dependencies`) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
'@graphql-hive/gateway': minor | ||
--- | ||
|
||
Introduce `target` as a new Hive reporting option | ||
|
||
Deprecate the `--hive-registry-token` CLI option in favour of `--hive-usage-target` and `--hive-usage-access-token` options. [Read more on Hive's product update page.](https://the-guild.dev/graphql/hive/product-updates/2025-03-10-new-access-tokens) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
'@graphql-hive/gateway-runtime': minor | ||
--- | ||
|
||
Introduce `target` as a new Hive reporting option | ||
|
||
[Read more on Hive's product update page.](https://the-guild.dev/graphql/hive/product-updates/2025-03-10-new-access-tokens) |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
import { | ||
CLIContext, | ||
GatewayConfig, | ||
GatewayGraphOSReportingOptions, | ||
GatewayHiveReportingOptions, | ||
} from '..'; | ||
|
||
export interface ReportingCLIOptions { | ||
hiveRegistryToken: string | undefined; | ||
hiveUsageTarget: string | undefined; | ||
hiveUsageAccessToken: string | undefined; | ||
apolloGraphRef: string | undefined; | ||
apolloKey: string | undefined; | ||
} | ||
|
||
export function handleReportingConfig( | ||
ctx: CLIContext, | ||
loadedConfig: Partial<GatewayConfig<Record<string, any>>>, | ||
cliOpts: ReportingCLIOptions, | ||
): GatewayHiveReportingOptions | GatewayGraphOSReportingOptions | null { | ||
const confOpts: Partial<ReportingCLIOptions> = { | ||
...(loadedConfig.reporting?.type === 'hive' | ||
? { | ||
hiveRegistryToken: loadedConfig.reporting.token, | ||
hiveUsageTarget: loadedConfig.reporting.target, | ||
hiveUsageAccessToken: loadedConfig.reporting.token, | ||
} | ||
: {}), | ||
...(loadedConfig.reporting?.type === 'graphos' | ||
? { | ||
apolloGraphRef: loadedConfig.reporting.graphRef, | ||
apolloKey: loadedConfig.reporting.apiKey, | ||
} | ||
: {}), | ||
}; | ||
const opts = { ...confOpts, ...cliOpts }; | ||
|
||
if (cliOpts.hiveRegistryToken && cliOpts.hiveUsageAccessToken) { | ||
ctx.log.error( | ||
`Cannot use "--hive-registry-token" with "--hive-usage-access-token". Please use "--hive-usage-target" and "--hive-usage-access-token" or the config instead.`, | ||
); | ||
process.exit(1); | ||
} | ||
|
||
if (cliOpts.hiveRegistryToken && opts.hiveUsageTarget) { | ||
ctx.log.error( | ||
`Cannot use "--hive-registry-token" with a target. Please use "--hive-usage-target" and "--hive-usage-access-token" or the config instead.`, | ||
); | ||
process.exit(1); | ||
} | ||
|
||
if (opts.hiveUsageTarget && !opts.hiveUsageAccessToken) { | ||
ctx.log.error( | ||
`Hive usage target needs an access token. Please provide it through the "--hive-usage-access-token <token>" option or the config.`, | ||
); | ||
process.exit(1); | ||
} | ||
|
||
if (opts.hiveUsageAccessToken && !opts.hiveUsageTarget) { | ||
ctx.log.error( | ||
`Hive usage access token needs a target. Please provide it through the "--hive-usage-target <target>" option or the config.`, | ||
); | ||
process.exit(1); | ||
} | ||
|
||
const hiveUsageAccessToken = | ||
opts.hiveUsageAccessToken || opts.hiveRegistryToken; | ||
if (hiveUsageAccessToken) { | ||
// different logs w and w/o the target to disambiguate | ||
if (opts.hiveUsageTarget) { | ||
ctx.log.info(`Configuring Hive usage reporting`); | ||
} else { | ||
ctx.log.info(`Configuring Hive registry reporting`); | ||
} | ||
return { | ||
...loadedConfig.reporting, | ||
type: 'hive', | ||
token: hiveUsageAccessToken, | ||
target: opts.hiveUsageTarget, | ||
}; | ||
} | ||
|
||
if (opts.apolloKey) { | ||
ctx.log.info(`Configuring Apollo GraphOS registry reporting`); | ||
if (!opts.apolloGraphRef) { | ||
ctx.log.error( | ||
`Apollo GraphOS requires a graph ref in the format <graph-id>@<graph-variant>. Please provide a valid graph ref.`, | ||
); | ||
process.exit(1); | ||
} | ||
return { | ||
...loadedConfig.reporting, | ||
type: 'graphos', | ||
apiKey: opts.apolloKey, | ||
graphRef: opts.apolloGraphRef, | ||
}; | ||
} | ||
|
||
return null; | ||
} |
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
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.