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

local composition with CLI #2750

Closed
n1ru4l opened this issue Aug 18, 2023 · 1 comment · Fixed by #4383
Closed

local composition with CLI #2750

n1ru4l opened this issue Aug 18, 2023 · 1 comment · Fixed by #4383
Labels
enhancement New feature or request that adds new things or value to Hive

Comments

@n1ru4l
Copy link
Collaborator

n1ru4l commented Aug 18, 2023

Sometimes when you want to develop locally it makes sense that you want to use the latest valid schema version on CDN, but replace some of the services locally because you develop locally.

The command should allow you to generate the supergraph and/or SDL locally (aka artifacts you would pass to a graphql gateway you run locally).

E.g. the following example would watch/poll htttp://localhost:3000/graphql, use the Hive GraphQL API for doing composition then write it to the supergraph.sdl file. If there was already a users service within the registry on GraphQL Hive it would be completely replaced by the local service.

hive dev --watch --service users --url http://localhost:3000/graphql  --out supergraph.sdl

If you want to replace multiple services locally you could just pass more parameters:

hive dev --watch \
  --service users --url http://localhost:3000/graphql \
  --service posts --url http://localhost:3001/graphql \
  --out supergraph.sdl

After each successful composition we could send a system push notification and/or display the changes on the CLI. 🤔

Note: We cannot do the composition locally as users could configure a wide range of custom external composition services. because of that we always need to do the composition through the API. In order to reduce the amount of network calls we can always check whether our local schemas have changed before doing the call.

Note: We cannot serve a gateway ourselves, as we don't know what composition type is used. We can only generate the artifact and write it to a file. Users are then advised to use their gateway of choice for consuming/watching that file.

@kamilkisiela
Copy link
Collaborator

https://the-guild.dev/graphql/hive/product-updates/2024-04-04-hive-dev-command

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request that adds new things or value to Hive
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants