Skip to content

Commit

Permalink
chore: implement tag inclusion for contracts (#1285)
Browse files Browse the repository at this point in the history
Co-authored-by: thisisnithin <nithinkumar5353@gmail.com>
  • Loading branch information
Aenimus and thisisnithin authored Oct 24, 2024
1 parent b16c2d0 commit fd3b388
Show file tree
Hide file tree
Showing 27 changed files with 12,988 additions and 6,235 deletions.
13 changes: 13 additions & 0 deletions cli/src/commands/contract/commands/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export default (opts: BaseCommandOptions) => {
'The routing url of your router. This is the url that the router will be accessible at.',
);
command.option('--exclude [tags...]', 'Schema elements with these tags will be excluded from the contract schema.');
command.option('--include [tags...]', 'Schema elements with these tags will be included from the contract schema.');
command.option(
'--admission-webhook-url <url>',
'The admission webhook url. This is the url that the controlplane will use to implement admission control for the contract graph.',
Expand All @@ -44,12 +45,24 @@ export default (opts: BaseCommandOptions) => {

const spinner = ora('Contract is being created...').start();

if (options.exclude.length > 0 && options.include.length > 0) {
program.error(
pc.red(
pc.bold(
`The "exclude" and "include" options for tags are currently mutually exclusive.` +
` Both options have been provided, but one of the options must be empty or unset.`,
),
),
);
}

const resp = await opts.client.platform.createContract(
{
name,
namespace: options.namespace,
sourceGraphName: options.source,
excludeTags: options.exclude,
includeTags: options.include,
routingUrl: options.routingUrl,
admissionWebhookUrl: options.admissionWebhookUrl,
admissionWebhookSecret: options.admissionWebhookSecret,
Expand Down
15 changes: 14 additions & 1 deletion cli/src/commands/contract/commands/update.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { EnumStatusCode } from '@wundergraph/cosmo-connect/dist/common/common_pb';
import Table from 'cli-table3';
import { Command } from 'commander';
import { Command, program } from 'commander';
import pc from 'picocolors';
import ora from 'ora';
import { getBaseHeaders } from '../../../core/config.js';
Expand All @@ -12,14 +12,27 @@ export default (opts: BaseCommandOptions) => {
command.argument('<name>', 'The name of the contract graph to update.');
command.option('-n, --namespace [string]', 'The namespace of the contract update.');
command.option('--exclude [tags...]', 'Schema elements with these tags will be excluded from the contract schema.');
command.option('--include [tags...]', 'Schema elements with these tags will be included from the contract schema.');
command.action(async (name, options) => {
const spinner = ora('Contract is being updated...').start();

if (options.exclude.length > 0 && options.include.length > 0) {
program.error(
pc.red(
pc.bold(
`The "exclude" and "include" options for tags are currently mutually exclusive.` +
` Both options have been provided, but one of the options must be empty or unset.`,
),
),
);
}

const resp = await opts.client.platform.updateContract(
{
name,
namespace: options.namespace,
excludeTags: options.exclude,
includeTags: options.include,
},
{
headers: getBaseHeaders(),
Expand Down
1 change: 1 addition & 0 deletions cli/src/commands/graph/federated-graph/commands/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type OutputFile = {
contract?: {
sourceFederatedGraphId: string;
excludeTags: string[];
includeTags: string[];
};
}[];

Expand Down
1 change: 1 addition & 0 deletions cli/src/commands/graph/monograph/commands/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ type OutputFile = {
contract?: {
sourceFederatedGraphId: string;
excludeTags: string[];
includeTags: string[];
};
}[];

Expand Down
112 changes: 56 additions & 56 deletions composition-go/index.global.js

Large diffs are not rendered by default.

Loading

0 comments on commit fd3b388

Please sign in to comment.