pcyan commented on issue #6266: URL: https://github.com/apache/apisix/issues/6266#issuecomment-1033224262
@tzssangglass 1. 一个正常的graphql请求 ```bash curl 'https://api.mocki.io/v2/c4d7a195/graphql' \ -H 'authority: api.mocki.io' \ -H 'accept: */*' \ -H 'content-type: application/json' \ -H 'origin: https://api.mocki.io' \ --data-raw '{"operationName":"getUser","variables":{},"query":"query getUser {\n user(id: \"4dc70521-22bb-4396-b37a-4a927c66d43b\") {\n id\n email\n name\n }\n}\n"}' \ --compressed ``` 会返回 ```json { "data": { "user": { "id": "Hello World", "email": "Hello World", "name": "Hello World" } } } ``` 2. 参照[apisix官方文档](https://apisix.apache.org/zh/docs/apisix/router-radixtree#%E5%A6%82%E4%BD%95%E9%80%9A%E8%BF%87-graphql-%E5%B1%9E%E6%80%A7%E8%BF%87%E6%BB%A4%E8%B7%AF%E7%94%B1),通过apisix配置 ```bash ### 添加测试的graphql请求 curl http://localhost:9080/apisix/admin/routes/7 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -i -d ' { "methods": ["POST"], "name":"mockGetUser", "uri": "/v2/c4d7a195/graphql", "vars": [ ["graphql_operation", "==", "query"], ["graphql_name", "==", "getUser"] ], "upstream": { "type": "roundrobin", "nodes": { "api.mocki.io": 1 } } }' ### apisix graphql curl 'https://localhost:9080/v2/c4d7a195/graphql' \ -H 'authority: api.mocki.io' \ -H 'accept: */*' \ -H 'content-type: application/json' \ -H 'origin: https://api.mocki.io' \ --data-raw '{"operationName":"getUser","variables":{},"query":"query getUser {\n user(id: \"4dc70521-22bb-4396-b37a-4a927c66d43b\") {\n id\n email\n name\n }\n}\n"}' \ --compressed ``` 会返回 ```json { "error_msg": "404 Route Not Found" } ``` 错误日志是` ctx.lua:80: get_parsed_graphql(): failed to parse graphql: Syntax error near line 1 body:` 麻烦你也试一下,或者告诉我是哪里配置错了 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
