You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by "SkyeYoung (via GitHub)" <gi...@apache.org> on 2023/03/09 10:53:02 UTC

[GitHub] [apisix-website] SkyeYoung commented on a diff in pull request #1526: docs: Add Apache APISIX 3.2 release blog

SkyeYoung commented on code in PR #1526:
URL: https://github.com/apache/apisix-website/pull/1526#discussion_r1130818449


##########
blog/zh/blog/2023/03/09/release-apache-apisix-3.1.0.md:
##########
@@ -0,0 +1,227 @@
+---
+title: "Apache APISIX 3.2.0 正式发布"
+authors:
+  - name: "罗泽轩"
+    title: "Author"
+    url: "https://github.com/spacewander"
+    image_url: "https://github.com/spacewander.png"
+  - name: "Yilialinn"
+    title: "Technical Writer"
+    url: "https://github.com/Yilialinn"
+    image_url: "https://avatars.githubusercontent.com/u/114121331?v=4"
+keywords: 
+- Apache APISIX
+- LTS
+description: APISIX 3.2.0 是 3.0 大版本以来的第一个 LTS 版本。此次发版,是 3.x 时代更替 2.x 时代的一大里程碑。从此之后,新的一系列 patch 版本将会在 3.2 的基础上发布。本次发布一如往常一样带来了许多新的插件和特性,为 APISIX 的使用者带来不一样的新玩法。
+tags: [Community]
+---
+
+> APISIX 3.2.0 是 3.0 大版本以来的第一个 LTS 版本。此次发版,是 3.x 时代更替 2.x 时代的一大里程碑。从此之后,新的一系列 patch 版本将会在 3.2 的基础上发布。本次发布一如往常一样带来了许多新的插件和特性,为 APISIX 的使用者带来不一样的新玩法。
+
+<!--truncate-->
+
+## 新特性:四层上的服务发现
+
+只有少数网关支持服务发现,APISIX 就是其中之一。在 3.2.0 版本中,APISIX 把原来七层上的服务发现的功能也做到了四层上。这样一来,将 APISIX 作为 TCP/UDP 代理时也能享受到服务发现带来的便利性。和在七层上的服务发现一样,要想用上服务发现,我们需要先在 `config.yaml` 中配置服务发现服务器的地址:
+
+```yaml
+discovery:
+  nacos:
+    host:
+      - "http://192.168.33.1:8848"
+```
+
+然后在具体的 upstream 上配置 `discovery_type` 和 `service_name`:
+
+```shell
+$ curl http://127.0.0.1:9180/apisix/admin/stream_routes/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -i -d '
+{
+    "remote_addr": "127.0.0.1",
+    "upstream": {
+        "scheme": "tcp",
+        "discovery_type": "nacos",
+        "service_name": "APISIX-NACOS",
+        "type": "roundrobin"
+    }
+}'
+```
+
+这样访问 stream_routes 时,上游的节点会从 Nacos 的 APISIX-NACOS 服务中获取。
+
+## 新插件:RESTful 请求转 graphQL
+
+在 3.2 版本中,APISIX 新增了一个能将 RESTful 请求转成 GraphQL 的插件。假如你有这样的 GraphQL 查询语句:
+
+```
+query($name: String!, $githubAccount: String!) {
+  persons(filter: { name: $name, githubAccount: $githubAccount }) {
+    id
+    name
+    blog
+    githubAccount
+    talks {
+      id
+      title
+    }
+  }
+}
+```
+
+其中 `$name` 和 `$githubAccount` 是两个 GraphQL 变量。
+
+我们可以用如下的配置来暴露出同样的 RESTful 接口:
+
+```shell
+curl --location --request PUT 'http://localhost:9180/apisix/admin/routes/1' \
+--header 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' \
+--header 'Content-Type: application/json' \
+--data-raw '{
+    "uri": "/graphql",
+    "upstream": {
+        "type": "roundrobin",
+        "nodes": {
+            "127.0.0.1:8080": 1
+        }
+    },
+    "plugins": {
+        "degraphql": {
+            "query": "query($name: String!, $githubAccount: String!) {\n  persons(filter: { name: $name, githubAccount: $githubAccount }) {\n    id\n    name\n    blog\n    githubAccount\n    talks {\n      id\n      title\n    }\n  }\n}",
+            "variables": [
+                "name",
+                "githubAccount"
+            ]
+        }
+    }
+}'
+```
+
+这里 query 是我们要用到的查询语句,variables 是事先声明的变量列表。

Review Comment:
   ```suggestion
   这里 `query` 是我们要用到的查询语句,`variables` 是事先声明的变量列表。
   ```



-- 
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: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org