feat: add topology query

This commit is contained in:
Fine 2024-01-08 16:23:57 +08:00
parent 26d0a8d681
commit 0523a04c51
3 changed files with 66 additions and 1 deletions

View File

@ -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
}
}
}`,
};

View File

@ -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}}`;

View File

@ -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;
},
},
});