Skip to content

Commit

Permalink
docs: Refactor the GET and POST requests
Browse files Browse the repository at this point in the history
  • Loading branch information
Chever-John committed Feb 28, 2022
1 parent 576bba7 commit 4a68a37
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 48 deletions.
26 changes: 2 additions & 24 deletions docs/en/latest/router-radixtree.md
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ We can define the following route:
```shell
$ curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -i -d '
{
"methods": ["POST"],
"methods": ["POST", "GET"],
"uri": "/_post",
"vars": [
["post_arg_name", "==", "json"]
Expand Down Expand Up @@ -313,29 +313,7 @@ query getRepo {
$ 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 way:
3. Try 'GET' request match

```shell
curl -H 'content-type: application/graphql' -X GET "http://127.0.0.1:9080/graphql?query=query getRepo { owner {name } repo {created}}" -g
Expand Down
26 changes: 2 additions & 24 deletions docs/zh/latest/router-radixtree.md
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ query getRepo {
```shell
$ curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -i -d '
{
"methods": ["POST"],
"methods": ["POST", "GET"],
"uri": "/_graphql",
"vars": [
["graphql_operation", "==", "query"],
Expand Down Expand Up @@ -314,29 +314,7 @@ query getRepo {
$ 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 匹配:
3. 尝试 GET 请求

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

0 comments on commit 4a68a37

Please sign in to comment.