wgc
Version:
The official CLI tool to manage the GraphQL Federation Platform Cosmo
32 lines • 1.25 kB
JavaScript
import { EnumStatusCode } from '@wundergraph/cosmo-connect/dist/common/common_pb';
import { getBaseHeaders } from '../../../core/config.js';
export const registerListSubgraphsTool = ({ server, opts }) => {
server.registerTool('list_subgraphs', {
title: 'List Subgraphs',
description: 'List all subgraphs',
}, async () => {
var _a, _b;
const resp = await opts.client.platform.getSubgraphs({
limit: 0,
offset: 0,
}, {
headers: getBaseHeaders(),
});
if (((_a = resp.response) === null || _a === void 0 ? void 0 : _a.code) !== EnumStatusCode.OK) {
throw new Error(`Could not fetch subgraphs: ${((_b = resp.response) === null || _b === void 0 ? void 0 : _b.details) || ''}`);
}
const out = resp.graphs.map((graph) => {
return {
id: graph.id,
name: graph.name,
labels: graph.labels,
routingURL: graph.routingURL,
lastUpdate: graph.lastUpdatedAt,
};
});
return {
content: [{ type: 'text', text: JSON.stringify(out, null, 2) }],
};
});
};
//# sourceMappingURL=list-subgraphs.js.map