Skip to content

Commit

Permalink
docs: add GET in document
Browse files Browse the repository at this point in the history
  • Loading branch information
Chever-John committed Feb 25, 2022
1 parent 23a71cd commit f64104f
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
28 changes: 28 additions & 0 deletions docs/en/latest/router-radixtree.md
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,34 @@ We can verify GraphQL matches in the following two ways:
$ curl -H 'content-type: application/json' -X POST http://127.0.0.1:9080/graphql --data '{"query": "query getRepo { owner {name } repo {created}}"}'
```

Next, try a GET request.
Let's first configure a route like this:
```shell
$ curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -i -d '
{
"methods": ["GET"],
"uri": "/_graphql",
"vars": [
["graphql_operation", "==", "query"],
["graphql_name", "==", "getRepo"],
["graphql_root_fields", "has", "owner"]
],
"upstream": {
"type": "roundrobin",
"nodes": {
"39.97.63.215:4000": 1
}
}
}'
```
We can verify GraphQL matches in the following two ways:
```shell
curl -H 'content-type: application/graphql' -X GET "http://127.0.0.1:9080/graphql?query=query getRepo { owner {name } repo {created}}" -g
```
H
To prevent spending too much time reading invalid GraphQL request body, we only read the first 1 MiB
data from the request body. This limitation is configured via:
Expand Down
28 changes: 28 additions & 0 deletions docs/zh/latest/router-radixtree.md
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,34 @@ $ curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f
$ curl -H 'content-type: application/json' -X POST http://127.0.0.1:9080/graphql --data '{"query": "query getRepo { owner {name } repo {created}}"}'
```

接下来,尝试一下 GET 请求。
我们首先配置这样的路由:

```shell
$ curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -i -d '
{
"methods": ["GET"],
"uri": "/_graphql",
"vars": [
["graphql_operation", "==", "query"],
["graphql_name", "==", "getRepo"],
["graphql_root_fields", "has", "owner"]
],
"upstream": {
"type": "roundrobin",
"nodes": {
"39.97.63.215:4000": 1
}
}
}'
```

我们可以通过以下两种方式分别去验证 GraphQL 匹配:

```shell
curl -H 'content-type: application/graphql' -X GET "http://127.0.0.1:9080/graphql?query=query getRepo { owner {name } repo {created}}" -g
```

为了防止花费太多时间读取无效的 `GraphQL` 请求正文,我们只读取前 `1 MiB`
来自请求体的数据。 此限制是通过以下方式配置的:

Expand Down

0 comments on commit f64104f

Please sign in to comment.