我正在尝试遵循GraphQL-Mesh中的示例并用我自己的端点替换端点以查看它是如何工作的。默认的 github 示例有效,但是当我尝试为我的示例提供网格时,它会引发以下错误:
$ "C:\Kiran\example\GraphQLMesh\node_modules\.bin\graphql-mesh" serve
Debugger listening on ws://127.0.0.1:64627/889629dc-8f00-446e-8927-5bdcd2791e10
For help, see: https://nodejs.org/en/docs/inspector
Debugger attached.
(node:13408) ExperimentalWarning: The fs.promises API is experimental
error: Unable to serve mesh: Cannot read property 'concat' of undefined {"stack":"TypeError: Cannot read property 'concat' of undefined\n at schemas.forEach (C:\\Kiran\\example\\GraphQLMesh\\node_modules\\@graphql-mesh\\odata\\index.cjs.js:493:51)\n at Array.forEach (<anonymous>)\n at ODataHandler.getMeshSource (C:\\Kiran\\example\\GraphQLMesh\\node_modules\\@graphql-mesh\\odata\\index.cjs.js:471:67)\n at process._tickCallback (internal/process/next_tick.js:68:7)"}
Waiting for the debugger to disconnect...
Done in 9.93s.
Waiting for the debugger to disconnect...
我.meshrc.yaml
的很简单,如下图
sources:
- name: Mytest
handler:
odata:
baseUrl: http://localhost:6001/odata/v1/
batch: multipart
expandNavProps: true
serve:
exampleQuery: northwind-example.graphql
并且 package.json 也只是 github 中的内容的副本
{
"name": "odata-example",
"version": "0.7.30",
"license": "MIT",
"private": true,
"scripts": {
"start": "graphql-mesh serve"
},
"dependencies": {
"@graphql-mesh/cli": "^0.12.1",
"@graphql-mesh/odata": "0.7.1",
"graphql": "^15.4.0"
}
}
当我点击http://localhost:6001/odata/v1/
Postman 上的 odata 端点 ( ) 时,我看到以下响应:
标题
Status Code: 200 OK
content-type: application/json; odata.metadata=minimal; odata.streaming=true; charset=utf-8
date: Sat, 05 Dec 2020 06:52:51 GMT
odata-version: 4.0
server: Kestrel
transfer-encoding: chunked
回复
{
"@odata.context": "http://localhost:6001/odata/v1/$metadata",
"value": [{
"name": "Products",
"kind": "EntitySet",
"url": "Products"
}, {
"name": "Categories",
"kind": "EntitySet",
"url": "Categories"
}, {
"name": "Suppliers",
"kind": "EntitySet",
"url": "Suppliers"
}]
}
我的示例查询也很简单,如下所示:
query fetchCatagories {
myCatagories {
CategoryId
CategoryName
Description
Products {
ProductName
OrderDetails {
OrderId
}
}
Catagories(queryOptions: { top: 1 }) {
Description
}
}
}
我在示例中缺少什么来使网格正常工作并生成 GraphQL 端点?
另外,我是否真的需要 OData 的 example.graphql,因为任何 OData 服务都将具有 /$metadata 端点来公开架构?
更新 1
我也不能让它与公共 odata 端点一起工作,比如https://services.odata.org/V3/OData/OData.svc/
只有默认示例端点有效
https://graph.microsoft.com/${GRAPH_VERSION:v1.0}
https://services.odata.org/TripPinRESTierService/(S(qzsyox3345c15qeq305pblvw))/
这里发生了什么?