Sn0rt opened a new issue, #8787: URL: https://github.com/apache/apisix/issues/8787
### Description DeGraphQL allows users to map URIs to fixed GraphQL queries through configuration, thereby converting GraphQL endpoints into ordinary endpoints. <h2>parameter</h2> name | type | option | default value | format | describe -- | -- | -- | -- | -- | -- endpoint | string | no | /graphql | | query | string | yes | “” | graphql json | The body of graphql that actually needs to be executed ## enable plugin You can enable the plugin in a specific route with the following command: ```bash curl "http://127.0.0.1:9180/apisix/admin/routes/1" \ -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d ' { "uri": "/me", "plugins": { "degraphql": { "endpoint": "/graphql", "query": "{\"query\":\"query{viewer{login}}\"}" } }, "upstream": { "scheme":"https", "nodes": { "api.github.com:443": 1 }, "type": "roundrobin" } }' ``` ## user case the user want map a resetful api /me to [[github.com/login](http://github.com/login)](http://github.com/login) info 1. enable plugin ```bash curl "http://127.0.0.1:9180/apisix/admin/routes/1" \ -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d ' { "uri": "/me", "plugins": { "degraphql": { "endpoint": "/graphql", "query": "{\"query\":\"query{viewer{login}}\"}" } }, "upstream": { "scheme":"https", "nodes": { "api.github.com:443": 1 }, "type": "roundrobin" } }' ``` 1. query route ```bash $ curl -s -X GET -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' "http://127.0.0.1:9180/apisix/admin/routes/1" | jq { "value": { "status": 1, "plugins": { "degraphql": { "query": "{\"query\":\"query{viewer{login}}\"}", "endpoint": "/graphql" } }, "update_time": 1675435553, "uri": "/me", "priority": 0, "create_time": 1675396064, "upstream": { "pass_host": "pass", "type": "roundrobin", "hash_on": "vars", "nodes": { "api.github.com:443": 1 }, "scheme": "https" }, "id": "1" }, "createdIndex": 31, "modifiedIndex": 735, "key": "/apisix/routes/1" } ``` 1. test ```bash curl -i -X GET "http://127.0.0.1:9080/me" -H "Host: api.github.com" -H "Authorization: bearer xxx" HTTP/1.1 200 OK Content-Type: application/json; charset=utf-8 Content-Length: 38 Connection: keep-alive Date: Thu, 02 Feb 2023 10:39:37 GMT X-OAuth-Scopes: audit_log, gist, notifications, project, user X-Accepted-OAuth-Scopes: repo github-authentication-token-expiration: 2023-05-03 07:06:06 UTC X-GitHub-Media-Type: github.v4; format=json X-RateLimit-Limit: 5000 X-RateLimit-Remaining: 4992 X-RateLimit-Reset: 1675335703 X-RateLimit-Used: 8 X-RateLimit-Resource: graphql Access-Control-Expose-Headers: ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset Access-Control-Allow-Origin: * Strict-Transport-Security: max-age=31536000; includeSubdomains; preload X-Frame-Options: deny X-Content-Type-Options: nosniff X-XSS-Protection: 0 Referrer-Policy: origin-when-cross-origin, strict-origin-when-cross-origin Content-Security-Policy: default-src 'none' Vary: Accept-Encoding, Accept, X-Requested-With X-GitHub-Request-Id: D111:7589:2F097:32432:63DB92E8 Server: APISIX/3.1.0 {"data":{"viewer":{"login":"Sn0rt"}}} ``` ### reference [https://docs.konghq.com/hub/kong-inc/degraphql/](https://docs.konghq.com/hub/kong-inc/degraphql/) -- 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]
