From c491d80fad9c906e93259285d932622c0ccbd628 Mon Sep 17 00:00:00 2001 From: AmaliMatharaarachchi Date: Mon, 1 Apr 2024 10:02:31 +0530 Subject: [PATCH 1/2] Add gql default support --- .../internal/oasparser/envoyconf/routes_with_clusters.go | 9 +++++++++ .../apk-confs/graphql/graphql_conf_without_sub.apk-conf | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/adapter/internal/oasparser/envoyconf/routes_with_clusters.go b/adapter/internal/oasparser/envoyconf/routes_with_clusters.go index cc3e4bfd2..b98a78988 100644 --- a/adapter/internal/oasparser/envoyconf/routes_with_clusters.go +++ b/adapter/internal/oasparser/envoyconf/routes_with_clusters.go @@ -186,6 +186,15 @@ func CreateRoutesWithClusters(adapterInternalAPI *model.AdapterInternalAPI, inte return nil, nil, nil, fmt.Errorf("error while creating routes. %v", err) } routes = append(routes, routesP...) + if adapterInternalAPI.IsDefaultVersion { + defaultRoutes, errDefaultPath := createRoutes(genRouteCreateParams(adapterInternalAPI, &resource, vHost, basePath, clusterName, nil, nil, organizationID, + false, true)) + if errDefaultPath != nil { + logger.LoggerXds.ErrorC(logging.PrintError(logging.Error2231, logging.MAJOR, "Error while creating routes for API %s %s for path: %s Error: %s", adapterInternalAPI.GetTitle(), adapterInternalAPI.GetVersion(), removeFirstOccurrence(resource.GetPath(), adapterInternalAPI.GetVersion()), errDefaultPath.Error())) + return nil, nil, nil, fmt.Errorf("error while creating routes. %v", errDefaultPath) + } + routes = append(routes, defaultRoutes...) + } return routes, clusters, endpoints, nil } for _, resource := range adapterInternalAPI.GetResources() { diff --git a/test/cucumber-tests/src/test/resources/artifacts/apk-confs/graphql/graphql_conf_without_sub.apk-conf b/test/cucumber-tests/src/test/resources/artifacts/apk-confs/graphql/graphql_conf_without_sub.apk-conf index b6b12e423..719091777 100644 --- a/test/cucumber-tests/src/test/resources/artifacts/apk-confs/graphql/graphql_conf_without_sub.apk-conf +++ b/test/cucumber-tests/src/test/resources/artifacts/apk-confs/graphql/graphql_conf_without_sub.apk-conf @@ -4,7 +4,7 @@ basePath: "/graphql" version: "3.14" type: "GRAPHQL" id: "graphql-without-sub" -defaultVersion: false +defaultVersion: true subscriptionValidation: false endpointConfigurations: production: From fc3258aef051b8b5e863e39893d04520d3f1ca14 Mon Sep 17 00:00:00 2001 From: AmaliMatharaarachchi Date: Mon, 1 Apr 2024 10:27:32 +0530 Subject: [PATCH 2/2] add gql default test --- .../src/test/resources/tests/api/GraphQL.feature | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/cucumber-tests/src/test/resources/tests/api/GraphQL.feature b/test/cucumber-tests/src/test/resources/tests/api/GraphQL.feature index dc3b2502b..ea144361a 100644 --- a/test/cucumber-tests/src/test/resources/tests/api/GraphQL.feature +++ b/test/cucumber-tests/src/test/resources/tests/api/GraphQL.feature @@ -19,6 +19,13 @@ Feature: Generating APK conf for GraphQL API | 429 | | 500 | And the response body should contain "\"name\":\"string\"" + Then I set headers + | Authorization | bearer ${accessToken} | + And I send "POST" request to "https://default.gw.wso2.com:9095/graphql" with body "{\"query\":\"{ allHumans { name } }\"}" + And I eventually receive 200 response code, not accepting + | 429 | + | 500 | + And the response body should contain "\"name\":\"string\"" Scenario: Undeploy API Given The system is ready