From 0523a04c51e0c9d507c5213e0b0dd20ee25758a2 Mon Sep 17 00:00:00 2001 From: Fine Date: Mon, 8 Jan 2024 16:23:57 +0800 Subject: [PATCH] feat: add topology query --- src/graphql/fragments/topology.ts | 36 +++++++++++++++++++++++++++++++ src/graphql/query/topology.ts | 11 +++++++++- src/store/modules/topology.ts | 20 +++++++++++++++++ 3 files changed, 66 insertions(+), 1 deletion(-) diff --git a/src/graphql/fragments/topology.ts b/src/graphql/fragments/topology.ts index 29580016..5d387fa8 100644 --- a/src/graphql/fragments/topology.ts +++ b/src/graphql/fragments/topology.ts @@ -99,3 +99,39 @@ export const ProcessTopology = { } `, }; +export const HierarchyServiceTopology = { + variable: "$serviceId: ID!, $layer: String!", + query: ` + hierarchyServiceTopology: getServiceHierarchy(serviceId: $serviceId, layer: $layer) { + relations { + upperService { + id + name + layer + } + lowerService { + id + name + layer + } + } + }`, +}; +export const HierarchyInstanceTopology = { + variable: "$instanceId: ID!, $layer: String!", + query: ` + HierarchyInstanceTopology: getInstanceHierarchy(instanceId: $instanceId, layer: $layer) { + relations { + upperInstance { + id + name + layer + } + lowerInstance { + id + name + layer + } + } + }`, +}; diff --git a/src/graphql/query/topology.ts b/src/graphql/query/topology.ts index fc627c8c..e4062819 100644 --- a/src/graphql/query/topology.ts +++ b/src/graphql/query/topology.ts @@ -14,9 +14,18 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { InstanceTopology, EndpointTopology, ServicesTopology, ProcessTopology } from "../fragments/topology"; +import { + InstanceTopology, + EndpointTopology, + ServicesTopology, + ProcessTopology, + HierarchyServiceTopology, + HierarchyInstanceTopology, +} from "../fragments/topology"; export const getInstanceTopology = `query queryData(${InstanceTopology.variable}) {${InstanceTopology.query}}`; export const getEndpointTopology = `query queryData(${EndpointTopology.variable}) {${EndpointTopology.query}}`; export const getServicesTopology = `query queryData(${ServicesTopology.variable}) {${ServicesTopology.query}}`; export const getProcessTopology = `query queryData(${ProcessTopology.variable}) {${ProcessTopology.query}}`; +export const getHierarchyInstanceTopology = `query queryData(${HierarchyInstanceTopology.variable}) {${HierarchyInstanceTopology.query}}`; +export const getHierarchyServiceTopology = `query queryData(${HierarchyServiceTopology.variable}) {${HierarchyServiceTopology.query}}`; diff --git a/src/store/modules/topology.ts b/src/store/modules/topology.ts index 6a12f252..666d717c 100644 --- a/src/store/modules/topology.ts +++ b/src/store/modules/topology.ts @@ -481,6 +481,26 @@ export const topologyStore = defineStore({ this.setLinkClientMetrics(res.data.data); return res.data; }, + async getHierarchyServiceTopology(params: { serviceId: string; layer: string }) { + if (!params.serviceId || !params.layer) { + return new Promise((resolve) => resolve({})); + } + const res: AxiosResponse = await graphql.query("getHierarchyServiceTopology").params(params); + if (res.data.errors) { + return res.data; + } + return res.data; + }, + async getHierarchyInstanceTopology(params: { instanceId: string; layer: string }) { + if (!params.instanceId || !params.layer) { + return new Promise((resolve) => resolve({})); + } + const res: AxiosResponse = await graphql.query("getHierarchyServiceTopology").params(params); + if (res.data.errors) { + return res.data; + } + return res.data; + }, }, });