我正在尝试根据前端中执行的操作来验证API响应中的某些数据以进行测试。在SVG页面上,我在节点之间创建了边,现在我需要验证边是否已创建。无法使用html代码进行验证。因此,正在寻找运行graphql查询并读取响应的方法。下面是我的查询
http://www./graphql
query PerspectiveGraph($perspective: String, $scenario: ID, $experiment:
ID) {
perspectiveGraph(
perspective: $perspective
scenario: $scenario
experiment: $experiment
) {
vertices {
_id
pool {
title
type
scenario {
_id
}
}
}
edges {
_to
_from
_id
pool {
role
description
scenario {
_id
}
}
}
}
}
作为回应,我将获得以下数据
{
"data": {
"perspectiveGraph": {
"vertices": [
{
"_id": "Vertices/10",
"pool": [
{
"title": "Initial Eligibility Determination",
"type": "esComponent",
"scenario": {
"_id": "Scenarios/p"
}
}
]
}
}
}
"edges": [
{
"_to": "Vertices/10",
"_from": "Vertices/8",
"_id": "Edges/176",
"pool": []
}
]
我需要通过搜索标题来从“顶点”块中获取ID,并验证顶点ID是否存在于“边”块中。请让我知道如何使用javascript在量角器中执行此操作 预先感谢