apisix-ingress-controller icon indicating copy to clipboard operation
apisix-ingress-controller copied to clipboard

request help: how to specific configuration of graphql via yaml

Open akalittle opened this issue 2 years ago • 8 comments

Issue description

Use GraphQL with API Gateway Apache APISIX

In the post, you use a http request to specific the graphql request. But How can I do this via yaml since I can't get definitions of grapql from ApisixRoute CRD.

Environment

apache/apisix:2.15.0-alpine apache/apisix-ingress-controller:1.4.1 docker.io/bitnami/etcd:3.5.4-debian-11-r14

Kubernetes cluster version: Client Version: v1.24.0 Kustomize Version: v4.5.4 Server Version: v1.21.12-gke.2200

akalittle avatar Aug 05 '22 06:08 akalittle

For our usage scenarios,if we have a lot of graphql queries like query a 、b、c and so on. We want to expose a and b query to public use, and c for private and authKey is needed to do authentication.

akalittle avatar Aug 05 '22 07:08 akalittle

you can refer to https://github.com/apache/apisix-ingress-controller/blob/dfcbaac8f2b8c9c5ece12e3454fa57a2a23dba65/samples/deploy/crd/v1/ApisixRoute.yaml#L665-L707

add some expr configurations.

tao12345666333 avatar Aug 05 '22 10:08 tao12345666333

you can refer to

https://github.com/apache/apisix-ingress-controller/blob/dfcbaac8f2b8c9c5ece12e3454fa57a2a23dba65/samples/deploy/crd/v1/ApisixRoute.yaml#L665-L707

add some expr configurations.

According to the file, only Cookie Header Path Query scope are supported. However in the graphql request, it pass all the data in body. The scope is Body maybe ?

{
	"query": "query Owner($transactionId: ID!) {\n  transaction(id: $transactionId) {\n    id\n    timestamp\n  }\n}\n",
	"variables": {
		"lpTokenId": null,
		"transactionId": "xxx"
	},
	"operationName": "Owner"
}

akalittle avatar Aug 06 '22 01:08 akalittle

Any updates on this ?

akalittle avatar Aug 17 '22 02:08 akalittle

@Chever-John Please help check this issue when you are free. I think you are more familiar with GraphQL + APISIX

tao12345666333 avatar Aug 19 '22 08:08 tao12345666333

@tao12345666333 @akalittle

This does seem to be my area of expertise, so leave it to me~

Estimated completion time: within 24 hours.

Chever-John avatar Aug 19 '22 08:08 Chever-John

The survey results are in: @akalittle is right. @tao12345666333 Now APISIX-ingress-controller does not support CRD resource configuration for GraphQL at this time. We need to add functionality for exprs.

@akalittle The following command may temporarily fulfill your needs.

kubectl exec -it -n ingress-apisix apisix-5bcf68b548-w8xkr -- curl http://127.0.0.1:9180/apisix/admin/routes/1 -H 'X-API-Key: edd1c9f034335f136f87ad84b625c8f1' -X PUT -i -d '
{
    "methods": ["POST"],
    "uri": "/graphql",
    "vars": [
        ["graphql_operation", "==", "query"],
        ["graphql_name", "==", "getRepo"],
        ["graphql_root_fields", "has", "owner"]
    ],
    "upstream": {
        "type": "roundrobin",
        "nodes": {
            "192.168.1.200:4000": 1
        }
    }
}'

@tao12345666333 I need to explain the mechanism of GraphQL briefly. The GraphQL phase is supposed to take effect only when the request goes to the GraphQL in APISIX. Our exprs have not reached this stage yet, so this is probably why match or exprs cannot resolve GraphQL requests.

Chever-John avatar Aug 21 '22 02:08 Chever-John

thanks

we can add it to TODO list.

But I won't make any promises. I'm happy to accept PRs from anyone

tao12345666333 avatar Aug 21 '22 02:08 tao12345666333

This issue has been marked as stale due to 90 days of inactivity. It will be closed in 30 days if no further activity occurs. If this issue is still relevant, please simply write any comment. Even if closed, you can still revive the issue at any time or discuss it on the [email protected] list. Thank you for your contributions.

github-actions[bot] avatar Nov 20 '22 01:11 github-actions[bot]

This issue has been marked as stale due to 90 days of inactivity. It will be closed in 30 days if no further activity occurs. If this issue is still relevant, please simply write any comment. Even if closed, you can still revive the issue at any time or discuss it on the [email protected] list. Thank you for your contributions.

github-actions[bot] avatar Feb 24 '23 01:02 github-actions[bot]

This issue has been closed due to lack of activity. If you think that is incorrect, or the issue requires additional review, you can revive the issue at any time.

github-actions[bot] avatar Mar 27 '23 01:03 github-actions[bot]

hi, will this ever get implemented ?

mfractal avatar May 23 '23 16:05 mfractal