wgc 0.8.2 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/commands/federated-graph/index.js +4 -6
- package/dist/commands/federated-graph/index.js.map +1 -1
- package/dist/commands/index.js +5 -1
- package/dist/commands/index.js.map +1 -1
- package/dist/commands/router/commands/compose.js +62 -0
- package/dist/commands/router/commands/compose.js.map +1 -0
- package/dist/commands/router/commands/fetch.d.ts +4 -0
- package/dist/commands/{federated-graph/commands/fetch-config.js → router/commands/fetch.js} +2 -2
- package/dist/commands/router/commands/fetch.js.map +1 -0
- package/dist/commands/router/index.d.ts +4 -0
- package/dist/commands/router/index.js +11 -0
- package/dist/commands/router/index.js.map +1 -0
- package/dist/commands/subgraph/commands/introspect.d.ts +4 -0
- package/dist/commands/subgraph/commands/introspect.js +32 -0
- package/dist/commands/subgraph/commands/introspect.js.map +1 -0
- package/dist/commands/subgraph/index.js +2 -0
- package/dist/commands/subgraph/index.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utils.d.ts +17 -0
- package/dist/utils.js +43 -0
- package/dist/utils.js.map +1 -0
- package/package.json +9 -5
- package/src/commands/federated-graph/index.ts +4 -6
- package/src/commands/index.ts +7 -1
- package/src/commands/router/commands/compose.ts +98 -0
- package/src/commands/{federated-graph/commands/fetch-config.ts → router/commands/fetch.ts} +1 -1
- package/src/commands/router/index.ts +12 -0
- package/src/commands/subgraph/commands/introspect.ts +40 -0
- package/src/commands/subgraph/index.ts +2 -0
- package/src/utils.ts +57 -0
- package/dist/commands/federated-graph/commands/fetch-config.js.map +0 -1
- /package/dist/commands/{federated-graph/commands/fetch-config.d.ts → router/commands/compose.d.ts} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,18 @@ Images can be found [here](https://github.com/orgs/wundergraph/packages?repo_nam
|
|
|
4
4
|
All notable changes to this project will be documented in this file.
|
|
5
5
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
6
6
|
|
|
7
|
+
# [0.9.0](https://github.com/wundergraph/cosmo/compare/wgc@0.8.3...wgc@0.9.0) (2023-09-11)
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* add introspect subgraph command ([#44](https://github.com/wundergraph/cosmo/issues/44)) ([bf376cd](https://github.com/wundergraph/cosmo/commit/bf376cd75382b16659efb670ea54494f691328aa)) (@JivusAyrus)
|
|
12
|
+
* introspect subgraphs in cli ([#53](https://github.com/wundergraph/cosmo/issues/53)) ([2bd9f95](https://github.com/wundergraph/cosmo/commit/2bd9f95cd3ac13e878a12ab526d575c9b1daf248)) (@JivusAyrus)
|
|
13
|
+
* router compose command ([#54](https://github.com/wundergraph/cosmo/issues/54)) ([109313a](https://github.com/wundergraph/cosmo/commit/109313a54d730e143d2b182fb7a72e7dd4386317)) (@thisisnithin)
|
|
14
|
+
|
|
15
|
+
## [0.8.3](https://github.com/wundergraph/cosmo/compare/wgc@0.8.2...wgc@0.8.3) (2023-09-08)
|
|
16
|
+
|
|
17
|
+
**Note:** Version bump only for package wgc
|
|
18
|
+
|
|
7
19
|
## [0.8.2](https://github.com/wundergraph/cosmo/compare/wgc@0.8.1...wgc@0.8.2) (2023-09-07)
|
|
8
20
|
|
|
9
21
|
**Note:** Version bump only for package wgc
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
|
-
import CreateFederatedGraphCommand from './commands/create.js';
|
|
3
|
-
import FetchFederatedGraphCommand from './commands/fetch.js';
|
|
4
|
-
import DeleteFederatedGraphCommand from './commands/delete.js';
|
|
5
|
-
import UpdateFederatedGraphCommand from './commands/update.js';
|
|
6
2
|
import CheckFederatedGraphCommand from './commands/check.js';
|
|
7
3
|
import CreateFederatedGraphToken from './commands/create-token.js';
|
|
8
|
-
import
|
|
4
|
+
import CreateFederatedGraphCommand from './commands/create.js';
|
|
5
|
+
import DeleteFederatedGraphCommand from './commands/delete.js';
|
|
6
|
+
import FetchFederatedGraphCommand from './commands/fetch.js';
|
|
9
7
|
import ListFederatedGraphs from './commands/list.js';
|
|
8
|
+
import UpdateFederatedGraphCommand from './commands/update.js';
|
|
10
9
|
export default (opts) => {
|
|
11
10
|
const schema = new Command('federated-graph');
|
|
12
11
|
schema.description('Provides commands for creating and managing a federated graph');
|
|
@@ -16,7 +15,6 @@ export default (opts) => {
|
|
|
16
15
|
schema.addCommand(UpdateFederatedGraphCommand(opts));
|
|
17
16
|
schema.addCommand(CheckFederatedGraphCommand(opts));
|
|
18
17
|
schema.addCommand(CreateFederatedGraphToken(opts));
|
|
19
|
-
schema.addCommand(FetchRouterConfig(opts));
|
|
20
18
|
schema.addCommand(ListFederatedGraphs(opts));
|
|
21
19
|
return schema;
|
|
22
20
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/federated-graph/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/federated-graph/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,0BAA0B,MAAM,qBAAqB,CAAC;AAC7D,OAAO,yBAAyB,MAAM,4BAA4B,CAAC;AACnE,OAAO,2BAA2B,MAAM,sBAAsB,CAAC;AAC/D,OAAO,2BAA2B,MAAM,sBAAsB,CAAC;AAC/D,OAAO,0BAA0B,MAAM,qBAAqB,CAAC;AAC7D,OAAO,mBAAmB,MAAM,oBAAoB,CAAC;AACrD,OAAO,2BAA2B,MAAM,sBAAsB,CAAC;AAE/D,eAAe,CAAC,IAAwB,EAAE,EAAE;IAC1C,MAAM,MAAM,GAAG,IAAI,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAC9C,MAAM,CAAC,WAAW,CAAC,+DAA+D,CAAC,CAAC;IACpF,MAAM,CAAC,UAAU,CAAC,2BAA2B,CAAC,IAAI,CAAC,CAAC,CAAC;IACrD,MAAM,CAAC,UAAU,CAAC,0BAA0B,CAAC,IAAI,CAAC,CAAC,CAAC;IACpD,MAAM,CAAC,UAAU,CAAC,2BAA2B,CAAC,IAAI,CAAC,CAAC,CAAC;IACrD,MAAM,CAAC,UAAU,CAAC,2BAA2B,CAAC,IAAI,CAAC,CAAC,CAAC;IACrD,MAAM,CAAC,UAAU,CAAC,0BAA0B,CAAC,IAAI,CAAC,CAAC,CAAC;IACpD,MAAM,CAAC,UAAU,CAAC,yBAAyB,CAAC,IAAI,CAAC,CAAC,CAAC;IACnD,MAAM,CAAC,UAAU,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC,CAAC;IAC7C,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC"}
|
package/dist/commands/index.js
CHANGED
|
@@ -2,9 +2,10 @@ import { Command } from 'commander';
|
|
|
2
2
|
import pc from 'picocolors';
|
|
3
3
|
import { CreateClient } from '../core/client/client.js';
|
|
4
4
|
import { config } from '../core/config.js';
|
|
5
|
-
import SchemaCommands from './subgraph/index.js';
|
|
6
5
|
import AuthCommands from './auth/index.js';
|
|
7
6
|
import FederatedGraphCommands from './federated-graph/index.js';
|
|
7
|
+
import RouterCommands from './router/index.js';
|
|
8
|
+
import SchemaCommands from './subgraph/index.js';
|
|
8
9
|
if (!config.apiKey) {
|
|
9
10
|
console.log(pc.yellow(`No API key found. Please create an API key and set as environment variable ${pc.bold('COSMO_API_KEY')}.` +
|
|
10
11
|
'\n' +
|
|
@@ -29,5 +30,8 @@ program.addCommand(SchemaCommands({
|
|
|
29
30
|
program.addCommand(AuthCommands({
|
|
30
31
|
client,
|
|
31
32
|
}));
|
|
33
|
+
program.addCommand(RouterCommands({
|
|
34
|
+
client,
|
|
35
|
+
}));
|
|
32
36
|
export default program;
|
|
33
37
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/commands/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/commands/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,YAAY,MAAM,iBAAiB,CAAC;AAC3C,OAAO,sBAAsB,MAAM,4BAA4B,CAAC;AAChE,OAAO,cAAc,MAAM,mBAAmB,CAAC;AAC/C,OAAO,cAAc,MAAM,qBAAqB,CAAC;AAEjD,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE;IAClB,OAAO,CAAC,GAAG,CACT,EAAE,CAAC,MAAM,CACP,8EAA8E,EAAE,CAAC,IAAI,CAAC,eAAe,CAAC,GAAG;QACvG,IAAI;QACJ,8EAA8E,CACjF,GAAG,IAAI,CACT,CAAC;CACH;AAED,MAAM,MAAM,GAAG,YAAY,CAAC;IAC1B,OAAO,EAAE,MAAM,CAAC,OAAO;IACvB,MAAM,EAAE,MAAM,CAAC,MAAM;CACtB,CAAC,CAAC;AAEH,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;AAC9B,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC;KACxC,WAAW,CAAC;;;CAGd,CAAC,CAAC;AAEH,OAAO,CAAC,UAAU,CAChB,sBAAsB,CAAC;IACrB,MAAM;CACP,CAAC,CACH,CAAC;AACF,OAAO,CAAC,UAAU,CAChB,cAAc,CAAC;IACb,MAAM;CACP,CAAC,CACH,CAAC;AACF,OAAO,CAAC,UAAU,CAChB,YAAY,CAAC;IACX,MAAM;CACP,CAAC,CACH,CAAC;AACF,OAAO,CAAC,UAAU,CAChB,cAAc,CAAC;IACb,MAAM;CACP,CAAC,CACH,CAAC;AAEF,eAAe,OAAO,CAAC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { existsSync } from 'node:fs';
|
|
2
|
+
import { readFile } from 'node:fs/promises';
|
|
3
|
+
import { buildRouterConfig } from '@wundergraph/cosmo-shared';
|
|
4
|
+
import { Command, program } from 'commander';
|
|
5
|
+
import { parse, printSchema } from 'graphql';
|
|
6
|
+
import * as yaml from 'js-yaml';
|
|
7
|
+
import { resolve } from 'pathe';
|
|
8
|
+
import pc from 'picocolors';
|
|
9
|
+
import { composeSubgraphs, introspectSubgraph } from '../../../utils.js';
|
|
10
|
+
export default (opts) => {
|
|
11
|
+
const command = new Command('compose');
|
|
12
|
+
command.description('Generates the router config locally. The output can be piped to a file.');
|
|
13
|
+
command.requiredOption('-i, --input <path-to-input>', 'The yaml file with data about graph and subgraphs.');
|
|
14
|
+
command.action(async (options) => {
|
|
15
|
+
var _a;
|
|
16
|
+
const inputFile = resolve(process.cwd(), options.input);
|
|
17
|
+
if (!existsSync(inputFile)) {
|
|
18
|
+
console.log(pc.red(pc.bold(`The input file '${pc.bold(inputFile)}' does not exist. Please check the path and try again.`)));
|
|
19
|
+
process.exit(1);
|
|
20
|
+
}
|
|
21
|
+
const fileContent = (await readFile(inputFile)).toString();
|
|
22
|
+
const config = yaml.load(fileContent);
|
|
23
|
+
const promises = [];
|
|
24
|
+
for (const s of config.graphs[0].subgraphs) {
|
|
25
|
+
const promise = introspectSubgraph({
|
|
26
|
+
subgraphURL: s.url,
|
|
27
|
+
additionalHeaders: Object.entries((_a = s.headers) !== null && _a !== void 0 ? _a : {}).map(([key, value]) => ({
|
|
28
|
+
key,
|
|
29
|
+
value,
|
|
30
|
+
})),
|
|
31
|
+
});
|
|
32
|
+
promises.push(promise);
|
|
33
|
+
}
|
|
34
|
+
const introspectResults = await Promise.all(promises);
|
|
35
|
+
if (introspectResults.some((r) => !r.success)) {
|
|
36
|
+
program.error('Could not introspect one or more subgraphs');
|
|
37
|
+
}
|
|
38
|
+
const result = composeSubgraphs(config.graphs[0].subgraphs.map((s, index) => ({
|
|
39
|
+
name: s.name,
|
|
40
|
+
url: s.url,
|
|
41
|
+
definitions: parse(introspectResults[index].sdl),
|
|
42
|
+
})));
|
|
43
|
+
if (result.errors && result.errors.length > 0) {
|
|
44
|
+
program.error(`Failed to compose: ${result.errors[0]}`);
|
|
45
|
+
}
|
|
46
|
+
if (!result.federationResult) {
|
|
47
|
+
program.error('Failed to compose given subgraphs');
|
|
48
|
+
}
|
|
49
|
+
const routerConfig = buildRouterConfig({
|
|
50
|
+
argumentConfigurations: result.federationResult.argumentConfigurations,
|
|
51
|
+
federatedSDL: printSchema(result.federationResult.federatedGraphSchema),
|
|
52
|
+
subgraphs: config.graphs[0].subgraphs.map((s, index) => ({
|
|
53
|
+
name: s.name,
|
|
54
|
+
url: s.url,
|
|
55
|
+
sdl: introspectResults[index].sdl,
|
|
56
|
+
})),
|
|
57
|
+
});
|
|
58
|
+
console.log(routerConfig.toJsonString());
|
|
59
|
+
});
|
|
60
|
+
return command;
|
|
61
|
+
};
|
|
62
|
+
//# sourceMappingURL=compose.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compose.js","sourceRoot":"","sources":["../../../../src/commands/router/commands/compose.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D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G,iBAAiB,CAAC;YACrC,sBAAsB,EAAE,MAAM,CAAC,gBAAgB,CAAC,sBAAsB;YACtE,YAAY,EAAE,WAAW,CAAC,MAAM,CAAC,gBAAgB,CAAC,oBAAoB,CAAC;YACvE,SAAS,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;gBACvD,IAAI,EAAE,CAAC,CAAC,IAAI;gBACZ,GAAG,EAAE,CAAC,CAAC,GAAG;gBACV,GAAG,EAAE,iBAAiB,CAAC,KAAK,CAAC,CAAC,GAAG;aAClC,CAAC,CAAC;SACJ,CAAC,CAAC;QAEH,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,YAAY,EAAE,CAAC,CAAC;IAC3C,CAAC,CAAC,CAAC;IAEH,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC"}
|
|
@@ -3,7 +3,7 @@ import pc from 'picocolors';
|
|
|
3
3
|
import { EnumStatusCode } from '@wundergraph/cosmo-connect/dist/common_pb';
|
|
4
4
|
import { baseHeaders } from '../../../core/config.js';
|
|
5
5
|
export default (opts) => {
|
|
6
|
-
const command = new Command('fetch
|
|
6
|
+
const command = new Command('fetch');
|
|
7
7
|
command.description('Fetches the latest valid router config for a federated graph. The output can be piped to a file.');
|
|
8
8
|
command.argument('<name>', 'The name of the federated graph to fetch.');
|
|
9
9
|
command.action(async (name, options) => {
|
|
@@ -24,4 +24,4 @@ export default (opts) => {
|
|
|
24
24
|
});
|
|
25
25
|
return command;
|
|
26
26
|
};
|
|
27
|
-
//# sourceMappingURL=fetch
|
|
27
|
+
//# sourceMappingURL=fetch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetch.js","sourceRoot":"","sources":["../../../../src/commands/router/commands/fetch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,E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
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import ComposeRouterConfig from './commands/compose.js';
|
|
3
|
+
import FetchRouterConfig from './commands/fetch.js';
|
|
4
|
+
export default (opts) => {
|
|
5
|
+
const cmd = new Command('router');
|
|
6
|
+
cmd.description('Provides commands for fetching and composing router configs');
|
|
7
|
+
cmd.addCommand(FetchRouterConfig(opts));
|
|
8
|
+
cmd.addCommand(ComposeRouterConfig(opts));
|
|
9
|
+
return cmd;
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/router/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,mBAAmB,MAAM,uBAAuB,CAAC;AACxD,OAAO,iBAAiB,MAAM,qBAAqB,CAAC;AAEpD,eAAe,CAAC,IAAwB,EAAE,EAAE;IAC1C,MAAM,GAAG,GAAG,IAAI,OAAO,CAAC,QAAQ,CAAC,CAAC;IAClC,GAAG,CAAC,WAAW,CAAC,6DAA6D,CAAC,CAAC;IAC/E,GAAG,CAAC,UAAU,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC,CAAC;IACxC,GAAG,CAAC,UAAU,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC,CAAC;IAC1C,OAAO,GAAG,CAAC;AACb,CAAC,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { splitLabel } from '@wundergraph/cosmo-shared';
|
|
2
|
+
import { Command } from 'commander';
|
|
3
|
+
import pc from 'picocolors';
|
|
4
|
+
import { introspectSubgraph } from '../../../utils.js';
|
|
5
|
+
import program from '../../index.js';
|
|
6
|
+
export default (opts) => {
|
|
7
|
+
const introspectSubgraphCmd = new Command('introspect');
|
|
8
|
+
introspectSubgraphCmd.description('Introspects a subgraph.');
|
|
9
|
+
introspectSubgraphCmd.requiredOption('-r, --routing-url <url>', 'The routing url of your subgraph. This is the url that the subgraph will be accessible at.');
|
|
10
|
+
introspectSubgraphCmd.option('--header [headers...]', 'The headers to apply when the subgraph is introspected. This is used for authentication and authorization.The headers are passed in the format <key>=<value> <key>=<value>.Use quotes if there exists space in the key/value.');
|
|
11
|
+
introspectSubgraphCmd.action(async (options) => {
|
|
12
|
+
var _a;
|
|
13
|
+
const resp = await introspectSubgraph({
|
|
14
|
+
subgraphURL: options.routingUrl,
|
|
15
|
+
additionalHeaders: ((_a = options.header) === null || _a === void 0 ? void 0 : _a.map((label) => {
|
|
16
|
+
const { key, value } = splitLabel(label);
|
|
17
|
+
return {
|
|
18
|
+
key,
|
|
19
|
+
value,
|
|
20
|
+
};
|
|
21
|
+
})) || [],
|
|
22
|
+
});
|
|
23
|
+
if (resp.success === true) {
|
|
24
|
+
console.log(resp.sdl);
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
program.error(pc.red('Could not introspect the subgraph.'));
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
return introspectSubgraphCmd;
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=introspect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"introspect.js","sourceRoot":"","sources":["../../../../src/commands/subgraph/commands/introspect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,OAAO,MAAM,gBAAgB,CAAC;AAErC,eAAe,CAAC,IAAwB,EAAE,EAAE;IAC1C,MAAM,qBAAqB,GAAG,IAAI,OAAO,CAAC,YAAY,CAAC,CAAC;IACxD,qBAAqB,CAAC,WAAW,CAAC,yBAAyB,CAAC,CAAC;IAC7D,qBAAqB,CAAC,cAAc,CAClC,yBAAyB,EACzB,4FAA4F,CAC7F,CAAC;IACF,qBAAqB,CAAC,MAAM,CAC1B,uBAAuB,EACvB,+NAA+N,CAChO,CAAC;IACF,qBAAqB,CAAC,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;;QAC7C,MAAM,IAAI,GAAG,MAAM,kBAAkB,CAAC;YACpC,WAAW,EAAE,OAAO,CAAC,UAAU;YAC/B,iBAAiB,EACf,CAAA,MAAA,OAAO,CAAC,MAAM,0CAAE,GAAG,CAAC,CAAC,KAAa,EAAE,EAAE;gBACpC,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC;gBACzC,OAAO;oBACL,GAAG;oBACH,KAAK;iBACN,CAAC;YACJ,CAAC,CAAC,KAAI,EAAE;SACX,CAAC,CAAC;QAEH,IAAI,IAAI,CAAC,OAAO,KAAK,IAAI,EAAE;YACzB,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;SACvB;aAAM;YACL,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,GAAG,CAAC,oCAAoC,CAAC,CAAC,CAAC;SAC7D;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,qBAAqB,CAAC;AAC/B,CAAC,CAAC"}
|
|
@@ -6,6 +6,7 @@ import DeleteSubgraph from './commands/delete.js';
|
|
|
6
6
|
import UpdateSubgraph from './commands/update.js';
|
|
7
7
|
import FixSubGraph from './commands/fix.js';
|
|
8
8
|
import ListSubgraphs from './commands/list.js';
|
|
9
|
+
import IntrospectSubgraph from './commands/introspect.js';
|
|
9
10
|
export default (opts) => {
|
|
10
11
|
const schema = new Command('subgraph');
|
|
11
12
|
schema.description('Provides commands for creating and maintaining subgraphs of a federated graph');
|
|
@@ -16,6 +17,7 @@ export default (opts) => {
|
|
|
16
17
|
schema.addCommand(UpdateSubgraph(opts));
|
|
17
18
|
schema.addCommand(FixSubGraph(opts));
|
|
18
19
|
schema.addCommand(ListSubgraphs(opts));
|
|
20
|
+
schema.addCommand(IntrospectSubgraph(opts));
|
|
19
21
|
return schema;
|
|
20
22
|
};
|
|
21
23
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/subgraph/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,aAAa,MAAM,qBAAqB,CAAC;AAChD,OAAO,qBAAqB,MAAM,sBAAsB,CAAC;AACzD,OAAO,eAAe,MAAM,uBAAuB,CAAC;AACpD,OAAO,cAAc,MAAM,sBAAsB,CAAC;AAClD,OAAO,cAAc,MAAM,sBAAsB,CAAC;AAClD,OAAO,WAAW,MAAM,mBAAmB,CAAC;AAC5C,OAAO,aAAa,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/subgraph/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,aAAa,MAAM,qBAAqB,CAAC;AAChD,OAAO,qBAAqB,MAAM,sBAAsB,CAAC;AACzD,OAAO,eAAe,MAAM,uBAAuB,CAAC;AACpD,OAAO,cAAc,MAAM,sBAAsB,CAAC;AAClD,OAAO,cAAc,MAAM,sBAAsB,CAAC;AAClD,OAAO,WAAW,MAAM,mBAAmB,CAAC;AAC5C,OAAO,aAAa,MAAM,oBAAoB,CAAC;AAC/C,OAAO,kBAAkB,MAAM,0BAA0B,CAAC;AAE1D,eAAe,CAAC,IAAwB,EAAE,EAAE;IAC1C,MAAM,MAAM,GAAG,IAAI,OAAO,CAAC,UAAU,CAAC,CAAC;IACvC,MAAM,CAAC,WAAW,CAAC,+EAA+E,CAAC,CAAC;IACpG,MAAM,CAAC,UAAU,CAAC,qBAAqB,CAAC,IAAI,CAAC,CAAC,CAAC;IAC/C,MAAM,C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