-
Notifications
You must be signed in to change notification settings - Fork 234
feat: onboarding wizard #5 #2750
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
comatory
merged 15 commits into
ondrej/eng-9192-onboarding-wizard-from-signup-to-live-metrics-topic
from
ondrej/eng-9192-onboarding-wizard-from-signup-to-live-metrics-05
Apr 29, 2026
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
0494934
feat: scaffold demo start command
comatory 43ecf80
feat: get user info
comatory 3f15dc9
feat: copy onboarding support files to filesystem
comatory 4af95e8
feat: check docker and buildx readiness during onboarding
comatory 508580b
feat: handle federated graph creation
comatory 4c2abde
feat: publish subgraphs as plugins
comatory b0994c7
feat: step 3 - obtain router token
comatory 362a303
feat: step 3 - run the router
comatory fab9c05
fix: handle CTRL+C during spinners
comatory 39ce0c2
refactor: use async/await when waiting for docker healthcheck
comatory a2d7e6a
fix: retry when router fails to start
comatory b4788e0
fix: always publish plugins to avoid broken states
comatory 62c6971
feat: open onboarding URL via prompt
comatory 4ce9de2
docs: demo command
comatory f775983
test: demo command
comatory 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
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,205 @@ | ||
| import { EnumStatusCode } from '@wundergraph/cosmo-connect/dist/common/common_pb'; | ||
| import type { FederatedGraph, Subgraph } from '@wundergraph/cosmo-connect/dist/platform/v1/platform_pb'; | ||
| import type { BaseCommandOptions } from '../../core/types/types.js'; | ||
| import { getBaseHeaders } from '../../core/config.js'; | ||
|
|
||
| /** | ||
| * Retrieve user information [email] and [organization name] | ||
| */ | ||
| export async function fetchUserInfo(client: BaseCommandOptions['client']) { | ||
| try { | ||
| const response = await client.platform.whoAmI( | ||
| {}, | ||
| { | ||
| headers: getBaseHeaders(), | ||
| }, | ||
| ); | ||
|
|
||
| switch (response.response?.code) { | ||
| case EnumStatusCode.OK: { | ||
| return { | ||
| userInfo: response, | ||
| error: null, | ||
| }; | ||
| } | ||
| default: { | ||
| return { | ||
| userInfo: null, | ||
| error: new Error(response.response?.details ?? 'An unknown error occurred.'), | ||
| }; | ||
| } | ||
| } | ||
| } catch (err) { | ||
| return { | ||
| userInfo: null, | ||
| error: err instanceof Error ? err : new Error('An unknown error occurred.'), | ||
| }; | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Retrieve onboarding record. Provides information about allowed [status]: | ||
| * [error] | [not-allowed] | [ok] | ||
| * If record exists, returns [onboarding] metadata. | ||
| */ | ||
| export async function checkExistingOnboarding(client: BaseCommandOptions['client']) { | ||
| const { response, finishedAt, enabled } = await client.platform.getOnboarding( | ||
| {}, | ||
| { | ||
| headers: getBaseHeaders(), | ||
| }, | ||
| ); | ||
|
|
||
| if (response?.code !== EnumStatusCode.OK) { | ||
| return { | ||
| error: new Error(response?.details ?? 'Failed to fetch onboarding metadata.'), | ||
| status: 'error', | ||
| } as const; | ||
| } | ||
|
|
||
| if (!enabled) { | ||
| return { | ||
| status: 'not-allowed', | ||
| } as const; | ||
| } | ||
|
|
||
| return { | ||
| onboarding: { | ||
| finishedAt, | ||
| }, | ||
| status: 'ok', | ||
| } as const; | ||
| } | ||
|
|
||
| /** | ||
| * Retrieves federated graph by [name] *demo*. Missing federated graph | ||
| * is a valid state. | ||
| */ | ||
| export async function fetchFederatedGraphByName( | ||
| client: BaseCommandOptions['client'], | ||
| { name, namespace }: { name: string; namespace: string }, | ||
| ) { | ||
| const { response, graph, subgraphs } = await client.platform.getFederatedGraphByName( | ||
| { | ||
| name, | ||
| namespace, | ||
| }, | ||
| { | ||
| headers: getBaseHeaders(), | ||
| }, | ||
| ); | ||
|
|
||
| switch (response?.code) { | ||
| case EnumStatusCode.OK: { | ||
| return { data: { graph, subgraphs }, error: null }; | ||
| } | ||
| case EnumStatusCode.ERR_NOT_FOUND: { | ||
| return { data: null, error: null }; | ||
| } | ||
| default: { | ||
| return { | ||
| data: null, | ||
| error: new Error(response?.details ?? 'An unknown error occured'), | ||
| }; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Cleans up the federated graph by [name] _demo_ and its related | ||
| * subgraphs. | ||
| */ | ||
| export async function cleanUpFederatedGraph( | ||
| client: BaseCommandOptions['client'], | ||
| graphData: { | ||
| graph: FederatedGraph; | ||
| subgraphs: Subgraph[]; | ||
| }, | ||
| ) { | ||
| const subgraphDeleteResponses = await Promise.all( | ||
| graphData.subgraphs.map(({ name, namespace }) => | ||
| client.platform.deleteFederatedSubgraph( | ||
| { | ||
| namespace, | ||
| subgraphName: name, | ||
| disableResolvabilityValidation: false, | ||
| }, | ||
| { | ||
| headers: getBaseHeaders(), | ||
| }, | ||
| ), | ||
| ), | ||
| ); | ||
|
|
||
| const failedSubgraphDeleteResponses = subgraphDeleteResponses.filter( | ||
| ({ response }) => response?.code !== EnumStatusCode.OK, | ||
| ); | ||
|
|
||
| if (failedSubgraphDeleteResponses.length > 0) { | ||
| return { | ||
| error: new Error( | ||
| failedSubgraphDeleteResponses.map(({ response }) => response?.details ?? 'Unknown error occurred.').join('. '), | ||
| ), | ||
| }; | ||
| } | ||
|
|
||
| const federatedGraphDeleteResponse = await client.platform.deleteFederatedGraph( | ||
| { | ||
| name: graphData.graph.name, | ||
| namespace: graphData.graph.namespace, | ||
| }, | ||
| { | ||
| headers: getBaseHeaders(), | ||
| }, | ||
| ); | ||
|
|
||
| switch (federatedGraphDeleteResponse.response?.code) { | ||
| case EnumStatusCode.OK: { | ||
| return { | ||
| error: null, | ||
| }; | ||
| } | ||
| default: { | ||
| return { | ||
| error: new Error(federatedGraphDeleteResponse.response?.details ?? 'Unknown error occurred.'), | ||
| }; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Creates federated graph using default [name] and [namespace], with pre-defined | ||
| * [labelMatcher] which identify the graph as _demo_. | ||
| */ | ||
| export async function createFederatedGraph( | ||
| client: BaseCommandOptions['client'], | ||
| options: { | ||
| name: string; | ||
| namespace: string; | ||
| labelMatcher: string; | ||
| routingUrl: URL; | ||
| }, | ||
| ) { | ||
| const createFedGraphResponse = await client.platform.createFederatedGraph( | ||
| { | ||
| name: options.name, | ||
| namespace: options.namespace, | ||
| routingUrl: options.routingUrl.toString(), | ||
| labelMatchers: [options.labelMatcher], | ||
| }, | ||
| { | ||
| headers: getBaseHeaders(), | ||
| }, | ||
| ); | ||
|
|
||
| switch (createFedGraphResponse.response?.code) { | ||
| case EnumStatusCode.OK: { | ||
| return { error: null }; | ||
| } | ||
| default: { | ||
| return { | ||
| error: new Error(createFedGraphResponse.response?.details ?? 'An unknown error occured'), | ||
| }; | ||
| } | ||
| } | ||
| } | ||
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.