Skip to content
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

Respect CLI arguments and configuration when both provided #342

Merged
merged 22 commits into from
Dec 19, 2024

Conversation

ardatan
Copy link
Member

@ardatan ardatan commented Dec 16, 2024

Closes #310

User can provide the token in the CLI arguments, and have some registry configuration in `gateway.config`

Since token can be provided in the CLI arguments, it should not be required in the configuration.

[Extra but needed] : Fixes in Test suite

Besides the changes in the code, I also saw that `bin` serve runner was not there and the tests were never running with the binary.
So I fixed it by adding bin serve runner implementation in the test suite.
I also found that process.env is not passed to the Docker runners as we do for other runners.

But I couldn't figure out why args not passed to the Docker runners, I need @enisdenjo 's help there because we test args here for Docker as in the original issue.

@ardatan ardatan force-pushed the test-self-hosting-hive branch from 0a3bbd0 to d1b889a Compare December 16, 2024 11:06
@ardatan ardatan changed the title Reproduction #310 Respect CLI arguments and configuration when both provided Dec 17, 2024
@theguild-bot
Copy link
Collaborator

theguild-bot commented Dec 17, 2024

🚀 Snapshot Release (alpha)

The latest changes of this PR are available as alpha on npm (based on the declared changesets):

Package Version Info
@graphql-mesh/fusion-runtime 0.10.23-alpha-8ff78beeb027abbd7fe46dcb5238a2aa1e371f96 npm ↗︎ unpkg ↗︎
@graphql-hive/gateway 1.7.2-alpha-8ff78beeb027abbd7fe46dcb5238a2aa1e371f96 npm ↗︎ unpkg ↗︎
@graphql-mesh/plugin-opentelemetry 1.3.30-alpha-8ff78beeb027abbd7fe46dcb5238a2aa1e371f96 npm ↗︎ unpkg ↗︎
@graphql-mesh/plugin-prometheus 1.3.18-alpha-8ff78beeb027abbd7fe46dcb5238a2aa1e371f96 npm ↗︎ unpkg ↗︎
@graphql-hive/gateway-runtime 1.4.2-alpha-8ff78beeb027abbd7fe46dcb5238a2aa1e371f96 npm ↗︎ unpkg ↗︎

@ardatan ardatan force-pushed the test-self-hosting-hive branch from f98bfd3 to 60f913c Compare December 17, 2024 07:58
@theguild-bot
Copy link
Collaborator

theguild-bot commented Dec 17, 2024

🚀 Snapshot Release (Binary for macOS-ARM64)

The latest changes of this PR are available for download (based on the declared changesets).

Download

@theguild-bot
Copy link
Collaborator

theguild-bot commented Dec 17, 2024

🚀 Snapshot Release (Binary for Linux-X64)

The latest changes of this PR are available for download (based on the declared changesets).

Download

@theguild-bot
Copy link
Collaborator

theguild-bot commented Dec 17, 2024

🚀 Snapshot Release (Bun Docker Image)

The latest changes of this PR are available as image on GitHub Container Registry (based on the declared changesets):

ghcr.io/graphql-hive/gateway:1.7.2-alpha-8ff78beeb027abbd7fe46dcb5238a2aa1e371f96-bun

@theguild-bot
Copy link
Collaborator

theguild-bot commented Dec 17, 2024

🚀 Snapshot Release (Node Docker Image)

The latest changes of this PR are available as image on GitHub Container Registry (based on the declared changesets):

ghcr.io/graphql-hive/gateway:1.7.2-alpha-8ff78beeb027abbd7fe46dcb5238a2aa1e371f96

@theguild-bot
Copy link
Collaborator

theguild-bot commented Dec 17, 2024

🚀 Snapshot Release (Binary for macOS-X64)

The latest changes of this PR are available for download (based on the declared changesets).

Download

@theguild-bot
Copy link
Collaborator

theguild-bot commented Dec 17, 2024

🚀 Snapshot Release (Binary for Windows-X64)

The latest changes of this PR are available for download (based on the declared changesets).

Download

@ardatan ardatan force-pushed the test-self-hosting-hive branch from 60f913c to 8e74782 Compare December 17, 2024 08:49
@ardatan ardatan marked this pull request as draft December 17, 2024 13:44
@ardatan ardatan force-pushed the test-self-hosting-hive branch from d69118c to 4ff3aec Compare December 18, 2024 12:24
@ardatan ardatan marked this pull request as ready for review December 18, 2024 12:24
@ardatan ardatan force-pushed the test-self-hosting-hive branch from 4ff3aec to 6e1ea3c Compare December 18, 2024 12:39
@Urigo
Copy link

Urigo commented Dec 18, 2024

where can I find the documentation that covers both cases to pass the arguments?

@ardatan
Copy link
Member Author

ardatan commented Dec 18, 2024

CLI Arguments reference -> https://the-guild.dev/graphql/hive/docs/api-reference/gateway-cli

We also have CLI configuration reference but it doesn't even mention about reporting;
https://the-guild.dev/graphql/hive/docs/api-reference/gateway-config

But instead we have this page for the configuration API for reporting
https://the-guild.dev/graphql/hive/docs/gateway/usage-reporting

And it is not clear how to pass other options like selfHosting :/

Comment on lines 188 to 189
/** GraphQL Hive registry access token. */
token: string;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no CLI or CLI arguments in the runtime. The token is still required in the runtime.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then we need to make it optional for CLI only?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about now? @enisdenjo

packages/gateway/src/config.ts Outdated Show resolved Hide resolved
@Urigo
Copy link

Urigo commented Dec 18, 2024

CLI Arguments reference -> the-guild.dev/graphql/hive/docs/api-reference/gateway-cli

We also have CLI configuration reference but it doesn't even mention about reporting; the-guild.dev/graphql/hive/docs/api-reference/gateway-config

But instead we have this page for the configuration API for reporting the-guild.dev/graphql/hive/docs/gateway/usage-reporting

And it is not clear how to pass other options like selfHosting :/

Thanks!
Let's improve the docs around these as part of this PR (I understand its on a different repo...)

@ardatan ardatan force-pushed the test-self-hosting-hive branch from 3ba9b3c to 1f7a032 Compare December 19, 2024 08:22
@@ -249,7 +250,9 @@ export const addCommand: AddCommand = (ctx, cli) =>
process.exit(1);
}
return runSupergraph(ctx, config);
});
})
.allowUnknownOption(process.env.NODE_ENV === 'test')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please elaborate on this change?

Copy link
Member Author

@ardatan ardatan Dec 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When running tests, NODE_ENV passed as test, and this allows us to accept extra CLI arguments.
We need this but why?
Because during tests random ports are used and the CLI needs to know which ports are used for which services.
Test suite passes those ports as arguments like --serviceName-port=13212
This was missing for GW CLI but only available for Mesh Compose. So in order to have a test self hosting service, we need to pass our test environment's port to the GW CLI.

Copy link
Member

@dotansimha dotansimha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Let's wait for @enisdenjo confirmation.
@ardatan , do we need docs updates for this change? I

@ardatan
Copy link
Member Author

ardatan commented Dec 19, 2024

Actually this is a PR for fixing a bug more than changing it. But I added docs for Hive Client reference here to make it clear for users need to use more features from Hive Console.

This is the PR improving docs for that purpose.
@dotansimha @Urigo
graphql-hive/console#6145

@ardatan ardatan force-pushed the test-self-hosting-hive branch from 4b76032 to 8ff78be Compare December 19, 2024 12:55
@ardatan ardatan requested a review from enisdenjo December 19, 2024 12:56
@ardatan ardatan merged commit 2f59fce into main Dec 19, 2024
34 of 36 checks passed
@ardatan ardatan deleted the test-self-hosting-hive branch December 19, 2024 15:56
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.

Self-hosted usage reporting not working
5 participants