pcyan opened a new issue #6266:
URL: https://github.com/apache/apisix/issues/6266


   ### Issue description
   
   use whole request body to parse graphql will get parse error. 
   graphql request body is json , example :`{"query":"query{getUser{name 
age}}","variables":null}`, not `query{getUser{name age}}`
   
   
   ### Environment
   
   - apisix version (cmd: `apisix version`):  `
   apache/apisix:2.12.0-alpine`
   - OS (cmd: `uname -a`): `docker `
   - OpenResty / Nginx version (cmd: `nginx -V` or `openresty -V`):  null
   - etcd version, if have (cmd: run `curl 
http://127.0.0.1:9090/v1/server_info` to get the info from server-info API):  
`bitnami/etcd:3.4.15`
   - apisix-dashboard version, if have: `
   apache/apisix-dashboard:2.10.1-alpine`
   - the plugin runner version, if the issue is about a plugin runner (cmd: 
depended on the kind of runner):
   - luarocks version, if the issue is about installation (cmd: `luarocks 
--version`):
   
   
   ### Steps to reproduce
   
   1. define graphql
   ```graphql
   query {
       getUser:User
   }
   
   type User{
       name:String
       age:String
   }
   ```
   2. add route
   ```bash
   curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: 
edd1c9f034335f136f87ad84b625c8f1' -X PUT -i -d '
   {
       "methods": ["POST"],
       "uri": "/graphql",
       "vars": [
           ["graphql_operation", "==", "query"],
           ["graphql_name", "==", "getUser"]
       ],
       "upstream": {
           "type": "roundrobin",
           "nodes": {
               "127.0.0.1:1980": 1
           }
       }
   }'
   ```
   3. perform graphql request by curl
   ```bash
   curl 'http://127.0.0.1:9080/graphql' \
     -H 'Content-Type: text/plain;charset=UTF-8' \
     -H 'Accept: */*' \
     --data-raw '{"query":"query getUser{getUser{name age}}","variables":null}' 
\
     --compressed
   ```
   
   ### Actual result
   
   HTTP/1.1 404 Not Found
   Date: Tue, 08 Feb 2022 07:39:16 GMT
   Content-Type: text/plain; charset=utf-8
   Transfer-Encoding: chunked
   Connection: keep-alive
   
   {
     "error_msg": "404 Route Not Found"
   }
   
   ### Error log
   
   2022/02/08 07:39:16 [error] 45#45: *1085159 [lua] ctx.lua:80: 
get_parsed_graphql(): failed to parse graphql: Syntax error near line 1 body: 
   
   ### Expected result
   
   success


-- 
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]


Reply via email to