我正在尝试使用npm GraphQL库从自省查询转换为GraphQL模式。
它一直在说明:
devAssert.mjs:7 Uncaught Error: Invalid or incomplete introspection result. Ensure that you are passing "data" property of introspection response and no "errors" was returned alongside: { ... }
问题是我直接从GraphiQL Shopify获得它,却无法弄清楚如何验证我的内省申报是否正确。
代码:
var introspection = `
{
"data": {
"__schema": {
"types": [
{
"name": "Boolean"
},{
"name": "String"
},{
"name": "QueryRoot"
},{
"name": "Job"
},{
"name": "ID"
},{
"name": "Node"
},{
"name": "Order"
}
]
}
},"extensions": {
"cost": {
"requestedQueryCost": 2,"actualQueryCost": 2,"throttleStatus": {
"maximumAvailable": 1000,"currentlyAvailable": 980,"restoreRate": 50
}
}
}
}`;
let schema = buildClientSchema(introspection);
//console.log(schema.printSchema());
我认为自省结果可能是字符串?还是没有足够的信息来构建模式?我是否需要扩展字段数?将自省结果转换为模式所需的最低限度是多少?