On Thu, Oct 29, 2020 at 5:44 PM Jan Li <[email protected]> wrote: > I think the support to GraphQL is the direction to go. > > One suggestion here, I think the support for GraphQL operation is also > important. > > For example, people might limit mutation rate to a lower value than query. > > So apart from ["graphql_field", "==", "person"], we better also support > ["graphql_operation", "==", "query"] > > yes, that is useful. agree
> On Thu, Oct 29, 2020 at 5:07 PM YuanSheng Wang <[email protected]> > wrote: > > > That is a new feature I want to implement it. > > > > Let us discuss it first. > > > > On Thu, Oct 29, 2020 at 5:05 PM YuanSheng Wang <[email protected]> > > wrote: > > > > > *what is GraphQL* > > > > > > GraphQL is a query language for APIs and a runtime for fulfilling those > > > queries with your existing data. GraphQL provides a complete and > > > understandable description of the data in your API, gives clients the > > power > > > to ask for exactly what they need and nothing more, makes it easier to > > > evolve APIs over time, and enables powerful developer tools. > > > > > > *How GraphQL works* > > > > > > `client` -> `APISIX` -> `GraphQL server` . > > > > > > Proxy the user's GraphQL request and forward it to the GraphQL server > > > according to the user's request information. > > > > > > When a client resource requests, GraphQL is submitted in the request > > body, > > > for example: > > > > > > ``` > > > curl http://***/graphql -X POST -d ' > > > query getUser($id: ID) { > > > person(id: $id) { > > > firstName > > > lastName > > > } > > > } > > > ' > > > ``` > > > > > > ## feature > > > > > > > **1th feature**: Forward to different requests upstream according to > > > the root field. > > > > > > ```lua > > > local graphql_str = [[ > > > query getUser($id: ID) { -- root > > > person(id: $id) { -- field 为 `person` > > > firstName > > > lastName > > > } > > > }]] > > > local ast = parse(graphql_str) > > > ... > > > ``` > > > > > > > **2th feature**: For different GraphQL queries, different plugins are > > > allowed to be bound. > > > > > > For example, querying different root fields allows completely different > > > plug-ins to be bound. > > > > > > * query `person`: enable plugin prometheus. > > > * query `bill`: enable plugin limit-count and prometheus. > > > > > > > **3th feature**: Later support GraphQL's `mutation`: > > > https://graphql.org/learn/queries/#mutations > > > > > > *implement way* > > > > > > Support adding GraphQL field to route matching conditions. > > > > > > For example: > > > > > > ```shell > > > curl http://127.0.0.1:9080/apisix/admin/routes/1 -X PUT -i -d ' > > > { > > > "uri": "/graphql", > > > "vars": [ > > > ["graphql_field", "==", "person"] > > > ], > > > "upstream": { > > > "type": "roundrobin", > > > "nodes": { > > > "127.0.0.1:3000": 1 # GrapQL server > > > } > > > } > > > }' > > > ``` > > > > > > -- > > > > > > *MembPhis* > > > My GitHub: https://github.com/membphis > > > Apache APISIX: https://github.com/apache/apisix > > > > > > > > > -- > > > > *MembPhis* > > My GitHub: https://github.com/membphis > > Apache APISIX: https://github.com/apache/apisix > > > > > -- > > > > Jan Li > > Senior Software Engineer, Tech > > > > Mobile +86 15316315503 > > Room 1802, 18th Floor, Tower A, China Overseas International Center > > Lane 838, South Huangpi Road, Huangpu District,Shanghai,China > > > > Transforming the way businesses move and manage money globally > > Amsterdam | Beijing | Bangalore | Hong Kong | Kuala Lumpur | London | > Melbourne | San Francisco | Shanghai | Shenzhen | Singapore | Tokyo > -- *MembPhis* My GitHub: https://github.com/membphis Apache APISIX: https://github.com/apache/apisix
