Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
2804f52
feat: add a feature to link subgraphs across namespaces
JivusAyrus Aug 20, 2025
9416d16
fix: pr suggestions
JivusAyrus Aug 20, 2025
40e0bb0
refactor: clean up linkSubgraph and unlinkSubgraph functions by remov…
JivusAyrus Aug 20, 2025
f7ec6e9
fix: update command options for linking subgraphs to use shorthand flags
JivusAyrus Aug 20, 2025
c857a12
feat: add linkSubgraph and unlinkSubgraph methods to PlatformService
JivusAyrus Aug 20, 2025
c63ce56
fix: tests
JivusAyrus Aug 20, 2025
f759e2b
refactor: implement transaction handling in linkSubgraph for improved…
JivusAyrus Aug 20, 2025
d122b94
feat: add is_subgraph_linked column to schema_checks and enhance subg…
JivusAyrus Aug 22, 2025
7328e1f
feat: add linked_schema_checks table and enhance schema check functio…
JivusAyrus Aug 26, 2025
383c856
feat: remove is_subgraph_linked column from schema_checks and update …
JivusAyrus Aug 26, 2025
1dbaa2b
fix: correct typo in error message for source namespace not found
JivusAyrus Aug 26, 2025
5ec57d2
feat: enforce NOT NULL constraints on linked_schema_checks table
JivusAyrus Aug 26, 2025
8b927db
fix: update labels assignment in checkSubgraphSchema function
JivusAyrus Aug 26, 2025
33ef538
Merge branch 'main' into suvij/eng-7794-create-subgraph-linking-on-cosmo
JivusAyrus Aug 26, 2025
6849be2
feat: enhance schema check functionality with linked subgraph checks
JivusAyrus Aug 28, 2025
7a35d13
refactor: streamline schema check response structure in checkSubgraph…
JivusAyrus Aug 28, 2025
ba3b7c9
feat: integrate linked schema check results into getCheckSummary
JivusAyrus Aug 28, 2025
121ee0a
feat: add LinkedCheck to GetCheckSummaryResponse and implement linked…
JivusAyrus Aug 28, 2025
74c0c8c
feat: add ui
JivusAyrus Aug 28, 2025
d0ea262
fix: ci
JivusAyrus Aug 28, 2025
b60a003
Merge branch 'main' into suvij/eng-7794-create-subgraph-linking-on-cosmo
JivusAyrus Aug 28, 2025
809133f
fix: handle conflicts when inserting linked schema checks in SchemaCh…
JivusAyrus Aug 28, 2025
4588b76
chore: add comments
JivusAyrus Aug 28, 2025
a13effc
feat: add detailed comments for linked check failure fields in CheckS…
JivusAyrus Aug 28, 2025
b47c78a
fix: correct typo in error message for nonexistent source namespace i…
JivusAyrus Aug 28, 2025
983310a
fix: ci
JivusAyrus Aug 28, 2025
68bc6d4
feat: enhance GetCheckSummaryResponse and related logic
JivusAyrus Aug 28, 2025
1b497fb
chore: merge migrations
JivusAyrus Aug 28, 2025
78d9540
Merge branch 'main' into suvij/eng-7794-create-subgraph-linking-on-cosmo
JivusAyrus Aug 28, 2025
1da21c6
fix: improve ui
JivusAyrus Aug 29, 2025
1f0bcd2
Merge branch 'suvij/eng-7794-create-subgraph-linking-on-cosmo' of git…
JivusAyrus Aug 29, 2025
bfa1829
fix: update heading for linked checks in CheckDetails component
JivusAyrus Aug 29, 2025
e677f19
feat: add LinkedCheck to SchemaCheck and update related logic
JivusAyrus Aug 29, 2025
124be3f
fix: adjust target limit in checkSubgraphSchema function
JivusAyrus Aug 29, 2025
1d9f833
fix: update hasClientTraffic logic in SubgraphRepository
JivusAyrus Aug 29, 2025
163516f
fix: include organizationId in linked schema check retrieval
JivusAyrus Aug 29, 2025
2dd7dfb
chore: revert
JivusAyrus Aug 29, 2025
4b7c8db
fix: compute GraphQL schema conditionally in checkSubgraphSchema func…
JivusAyrus Aug 29, 2025
a87a212
fix: enhance linked schema check retrieval with organization context
JivusAyrus Aug 31, 2025
67bf6dd
feat: add linked subgraph support to GetSubgraphByNameResponse
JivusAyrus Aug 31, 2025
509dcdc
fix: typo
JivusAyrus Aug 31, 2025
5266a00
fix: correct punctuation in linked check failure message for clarity
JivusAyrus Sep 1, 2025
422f446
fix: pr suggestions
JivusAyrus Sep 3, 2025
925770c
refactor: remove reason display from check details component
JivusAyrus Sep 3, 2025
f53f290
Merge branch 'main' into suvij/eng-7794-create-subgraph-linking-on-cosmo
JivusAyrus Sep 3, 2025
2d449de
feat: enhance subgraph verification checks
JivusAyrus Sep 4, 2025
090c794
fix: lint
JivusAyrus Sep 4, 2025
d88c2e6
fix: improve target subgraph validation
JivusAyrus Sep 4, 2025
e0bc161
fix: add validation for identical source and target subgraphs
JivusAyrus Sep 4, 2025
71b6df9
fix: prevent self-linking of subgraphs
JivusAyrus Sep 4, 2025
2936b7f
fix: update schema parsing in subgraph validation
JivusAyrus Sep 4, 2025
c176c96
fix: refine GraphQL schema computation logic
JivusAyrus Sep 4, 2025
de07989
Merge branch 'main' into suvij/eng-7794-create-subgraph-linking-on-cosmo
JivusAyrus Sep 4, 2025
e65e62c
fix: update link command description for clarity
JivusAyrus Sep 4, 2025
7972033
feat: enhance InfoTooltip and Alert components
JivusAyrus Sep 4, 2025
6be6324
fix: correct typo in link command description
JivusAyrus Sep 4, 2025
eefab47
refactor: update SchemaCheck to support multiple linked checks
JivusAyrus Sep 8, 2025
19f706e
fix: correct target subgraph option syntax in link command
JivusAyrus Sep 8, 2025
7d4020b
Merge branch 'main' into suvij/eng-7794-create-subgraph-linking-on-cosmo
JivusAyrus Sep 8, 2025
90a1cf3
fix: update hasClientTraffic logic in checkSubgraphSchema
JivusAyrus Sep 8, 2025
9ad97dc
feat: add isForcedSuccess field to SchemaCheck and related components
JivusAyrus Sep 8, 2025
9ce750f
test: add validation for checks associated with contracts in federate…
JivusAyrus Sep 8, 2025
337d976
Merge branch 'main' into suvij/eng-7794-create-subgraph-linking-on-cosmo
JivusAyrus Sep 9, 2025
1551163
fix: update namespace option syntax in link and unlink commands
JivusAyrus Sep 10, 2025
871f60a
Merge branch 'main' into suvij/eng-7794-create-subgraph-linking-on-cosmo
JivusAyrus Sep 10, 2025
9ad06b8
feat: enhance proposal handling with linked traffic and pruning checks
JivusAyrus Sep 10, 2025
5bec09a
refactor: update linked checks logic to account for forced success
JivusAyrus Sep 10, 2025
f4a09e4
refactor: standardize linked checks logic formatting
JivusAyrus Sep 10, 2025
c8f9de4
Merge branch 'main' into suvij/eng-7794-create-subgraph-linking-on-cosmo
JivusAyrus Sep 10, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions cli/src/commands/mcp/tools/subgraph-verify-schema-changes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ export const registerSubgraphVerifySchemaChangesTool = ({ server, opts }: ToolCo
clientTrafficCheckSkipped: resp.clientTrafficCheckSkipped === true,
hasProposalMatchError:
resp.response?.code === EnumStatusCode.ERR_SCHEMA_MISMATCH_WITH_APPROVED_PROPOSAL,
isLinkedTrafficCheckFailed: resp.isLinkedTrafficCheckFailed,
isLinkedPruningCheckFailed: resp.isLinkedPruningCheckFailed,
}),
},
null,
Expand All @@ -68,6 +70,8 @@ const isCheckSuccessful = ({
hasGraphPruningErrors,
clientTrafficCheckSkipped,
hasProposalMatchError,
isLinkedTrafficCheckFailed,
isLinkedPruningCheckFailed,
}: {
isComposable: boolean;
isBreaking: boolean;
Expand All @@ -76,7 +80,14 @@ const isCheckSuccessful = ({
hasGraphPruningErrors: boolean;
clientTrafficCheckSkipped: boolean;
hasProposalMatchError: boolean;
isLinkedTrafficCheckFailed?: boolean;
isLinkedPruningCheckFailed?: boolean;
}) => {
// if a subgraph is linked to another subgraph, then the status of the check depends on the traffic and pruning check of the linked subgraph
if (isLinkedTrafficCheckFailed || isLinkedPruningCheckFailed) {
return false;
}

return (
isComposable &&
// If no breaking changes found
Expand Down
62 changes: 62 additions & 0 deletions cli/src/commands/subgraph/commands/link.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import { EnumStatusCode } from '@wundergraph/cosmo-connect/dist/common/common_pb';
import { Command, program } from 'commander';
import ora from 'ora';
import pc from 'picocolors';
import { getBaseHeaders } from '../../../core/config.js';
import { BaseCommandOptions } from '../../../core/types/types.js';

export default (opts: BaseCommandOptions) => {
const command = new Command('link');
command.description(
'Links a subgraph to another subgraph on the control plane. When performing schema checks on the source subgraph, traffic and pruning checks will also be performed on the target subgraph. This is useful for verifying the impact of the schema changes before they are propagated to the next environment.',
);
command.argument('<source-subgraph-name>', 'The name of the subgraph to link.');
command.option('-n, --namespace <string>', 'The namespace of the source subgraph.', 'default');
command.requiredOption(
'-t, --target-subgraph <string>',
'The name of the subgraph to link to. Format: <namespace>/<subgraph-name>',
);

command.action(async (name, options) => {
// Split on all slashes, take first as namespace, join rest as subgraph name
const [targetNamespace, ...rest] = options.targetSubgraph.split('/');
if (!targetNamespace || rest.length === 0) {
program.error('Target subgraph must be in the format <namespace>/<subgraph-name>');
}

const targetSubgraphName = rest.join('/');

// Prevent self-linking
if (options.namespace === targetNamespace && name === targetSubgraphName) {
program.error('The source and target subgraphs cannot be the same subgraphs.');
}

const spinner = ora(`The subgraph "${name}" is being linked to "${targetSubgraphName}"...`).start();

const resp = await opts.client.platform.linkSubgraph(
{
sourceSubgraphName: name,
sourceSubgraphNamespace: options.namespace,
targetSubgraphName,
targetSubgraphNamespace: targetNamespace,
},
{
headers: getBaseHeaders(),
},
);

if (resp.response?.code === EnumStatusCode.OK) {
spinner.succeed('Subgraph was linked successfully.');
} else {
spinner.fail('Failed to link subgraph.');
if (resp.response?.details) {
console.log(pc.red(pc.bold(resp.response?.details)));
}
process.exitCode = 1;
// eslint-disable-next-line no-useless-return
return;
}
Comment thread
JivusAyrus marked this conversation as resolved.
});

return command;
};
41 changes: 41 additions & 0 deletions cli/src/commands/subgraph/commands/unlink.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { EnumStatusCode } from '@wundergraph/cosmo-connect/dist/common/common_pb';
import { Command } from 'commander';
import ora from 'ora';
import pc from 'picocolors';
import { getBaseHeaders } from '../../../core/config.js';
import { BaseCommandOptions } from '../../../core/types/types.js';

export default (opts: BaseCommandOptions) => {
const command = new Command('unlink');
command.description('Unlinks a subgraph from another subgraph on the control plane.');
command.argument('<source-subgraph-name>', 'The name of the subgraph to unlink.');
command.option('-n, --namespace <string>', 'The namespace of the source subgraph.', 'default');

command.action(async (name, options) => {
const spinner = ora(`The subgraph "${name}" is being unlinked...`).start();

const resp = await opts.client.platform.unlinkSubgraph(
{
sourceSubgraphName: name,
sourceSubgraphNamespace: options.namespace,
},
{
headers: getBaseHeaders(),
},
);

if (resp.response?.code === EnumStatusCode.OK) {
spinner.succeed('Subgraph was unlinked successfully.');
} else {
spinner.fail('Failed to unlink subgraph.');
if (resp.response?.details) {
console.log(pc.red(pc.bold(resp.response?.details)));
}
process.exitCode = 1;
// eslint-disable-next-line no-useless-return
return;
}
Comment thread
JivusAyrus marked this conversation as resolved.
});

return command;
};
4 changes: 4 additions & 0 deletions cli/src/commands/subgraph/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import ListSubgraphs from './commands/list.js';
import IntrospectSubgraph from './commands/introspect.js';
import MoveSubgraph from './commands/move.js';
import FetchSubgraph from './commands/fetch.js';
import LinkSubgraph from './commands/link.js';
import UnlinkSubgraph from './commands/unlink.js';

export default (opts: BaseCommandOptions) => {
const command = new Command('subgraph');
Expand All @@ -25,6 +27,8 @@ export default (opts: BaseCommandOptions) => {
command.addCommand(IntrospectSubgraph(opts));
command.addCommand(MoveSubgraph(opts));
command.addCommand(FetchSubgraph(opts));
command.addCommand(LinkSubgraph(opts));
command.addCommand(UnlinkSubgraph(opts));

command.hook('preAction', async (thisCmd) => {
await checkAuth();
Expand Down
15 changes: 15 additions & 0 deletions cli/src/handle-check-result.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,21 @@ export const handleCheckResult = (resp: CheckSubgraphSchemaResponse) => {
console.log(graphPruningIssuesTable.toString());
}

if (resp.isLinkedTrafficCheckFailed || resp.isLinkedPruningCheckFailed) {
finalStatement += success
? `\n\n But this schema change has been linked to a target subgraph and the target subgraph check has failed.`
: `\n\n This schema change has been linked to a target subgraph and the target subgraph check has failed.`;

if (resp.isLinkedTrafficCheckFailed) {
finalStatement += `\n\n The target subgraph check has failed because of client traffic issues.`;
}

if (resp.isLinkedPruningCheckFailed) {
finalStatement += `\n\n The target subgraph check has failed because of graph pruning issues.`;
}
success = false;
}

if (success) {
console.log(
'\n' +
Expand Down
15 changes: 15 additions & 0 deletions cli/src/handle-proposal-result.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,21 @@ export const handleProposalResult = (
console.log(graphPruningIssuesTable.toString());
}

if (resp.isLinkedTrafficCheckFailed || resp.isLinkedPruningCheckFailed) {
finalStatement += success
? `\n\n But this schema change has been linked to a target subgraph and the target subgraph check has failed.`
: `\n\n This schema change has been linked to a target subgraph and the target subgraph check has failed.`;

if (resp.isLinkedTrafficCheckFailed) {
finalStatement += `\n\n The target subgraph check has failed because of client traffic issues.`;
}

if (resp.isLinkedPruningCheckFailed) {
finalStatement += `\n\n The target subgraph check has failed because of graph pruning issues.`;
}
success = false;
}

if (success) {
console.log(
'\n' +
Expand Down
Loading
Loading