From 48851082747445bc70f7e5d6321049a5cb310c4e Mon Sep 17 00:00:00 2001 From: CrowleyRajapakse Date: Tue, 20 Feb 2024 11:24:32 +0530 Subject: [PATCH] adding changes/fixes related graphql APIs --- .../config/crd/bases/dp.wso2.com_gqlroutes.yaml | 1 + helm-charts/crds/dp.wso2.com_gqlroutes.yaml | 1 + runtime/config-deployer-service/ballerina/APIClient.bal | 6 +++--- .../config-deployer-service/ballerina/Dependencies.toml | 8 ++++---- .../ballerina/Dependencies.toml.template | 6 +++--- .../ballerina/modules/model/GraphQLRoute.bal | 7 +++++-- .../src/test/resources/tests/api/GraphQL.feature | 2 +- 7 files changed, 18 insertions(+), 13 deletions(-) diff --git a/common-go-libs/config/crd/bases/dp.wso2.com_gqlroutes.yaml b/common-go-libs/config/crd/bases/dp.wso2.com_gqlroutes.yaml index 5537761a1..13215368a 100644 --- a/common-go-libs/config/crd/bases/dp.wso2.com_gqlroutes.yaml +++ b/common-go-libs/config/crd/bases/dp.wso2.com_gqlroutes.yaml @@ -872,6 +872,7 @@ spec: enum: - QUERY - MUTATION + - SUBSCRIPTION type: string type: object type: array diff --git a/helm-charts/crds/dp.wso2.com_gqlroutes.yaml b/helm-charts/crds/dp.wso2.com_gqlroutes.yaml index 557436f2d..d9a8e8ed7 100644 --- a/helm-charts/crds/dp.wso2.com_gqlroutes.yaml +++ b/helm-charts/crds/dp.wso2.com_gqlroutes.yaml @@ -873,6 +873,7 @@ spec: enum: - QUERY - MUTATION + - SUBSCRIPTION type: string type: object type: array diff --git a/runtime/config-deployer-service/ballerina/APIClient.bal b/runtime/config-deployer-service/ballerina/APIClient.bal index 1910545d3..d6441725f 100644 --- a/runtime/config-deployer-service/ballerina/APIClient.bal +++ b/runtime/config-deployer-service/ballerina/APIClient.bal @@ -659,8 +659,8 @@ public class APIClient { model:APIPolicy? apiPolicyCR = check self.generateAPIPolicyAndBackendCR(apiArtifact, apkConf, operation, operation.operationPolicies, organization, apiArtifact.uniqueId); if apiPolicyCR != () { apiArtifact.apiPolicies[apiPolicyCR.metadata.name] = apiPolicyCR; - model:HTTPRouteFilter apiPolicyFilter = {'type: "ExtensionRef", extensionRef: {group: "dp.wso2.com", kind: "APIPolicy", name: apiPolicyCR.metadata.name}}; - (filters).push(apiPolicyFilter); + model:GQLRouteFilter apiPolicyFilter = {extensionRef: {group: "dp.wso2.com", kind: apiPolicyCR.kind, name: apiPolicyCR.metadata.name}}; + (filters).push(apiPolicyFilter); } } gqlRouteRules.push(routeRule); @@ -762,7 +762,7 @@ public class APIClient { model:GQLRouteRule gqlRouteRule = {matches: routeMatches}; return gqlRouteRule; } else { - return e909022("Subscription type currently not supported for GraphQL APIs.", error("Subscription type currently not supported for GraphQL APIs.")); + return e909022("Provided Type currently not supported for GraphQL APIs.", error("Provided Type currently not supported for GraphQL APIs.")); } } else { model:HTTPRouteRule httpRouteRule = {matches: self.retrieveHTTPMatches(apkConf, operation, organization), backendRefs: self.retrieveGeneratedBackend(apkConf, endpointToUse, endpointType), filters: self.generateFilters(apiArtifact, apkConf, endpointToUse, operation, endpointType, organization)}; diff --git a/runtime/config-deployer-service/ballerina/Dependencies.toml b/runtime/config-deployer-service/ballerina/Dependencies.toml index a04efcddd..712f21585 100644 --- a/runtime/config-deployer-service/ballerina/Dependencies.toml +++ b/runtime/config-deployer-service/ballerina/Dependencies.toml @@ -22,7 +22,7 @@ dependencies = [ [[package]] org = "ballerina" name = "cache" -version = "3.7.0" +version = "3.7.1" dependencies = [ {org = "ballerina", name = "constraint"}, {org = "ballerina", name = "jballerina.java"}, @@ -70,7 +70,7 @@ modules = [ [[package]] org = "ballerina" name = "http" -version = "2.10.0" +version = "2.10.7" dependencies = [ {org = "ballerina", name = "auth"}, {org = "ballerina", name = "cache"}, @@ -273,7 +273,7 @@ dependencies = [ [[package]] org = "ballerina" name = "observe" -version = "1.2.0" +version = "1.2.2" dependencies = [ {org = "ballerina", name = "jballerina.java"} ] @@ -302,7 +302,7 @@ modules = [ [[package]] org = "ballerina" name = "sql" -version = "1.11.0" +version = "1.11.1" dependencies = [ {org = "ballerina", name = "io"}, {org = "ballerina", name = "jballerina.java"}, diff --git a/runtime/config-deployer-service/ballerina/Dependencies.toml.template b/runtime/config-deployer-service/ballerina/Dependencies.toml.template index 3023a9e10..526506973 100644 --- a/runtime/config-deployer-service/ballerina/Dependencies.toml.template +++ b/runtime/config-deployer-service/ballerina/Dependencies.toml.template @@ -22,7 +22,7 @@ dependencies = [ [[package]] org = "ballerina" name = "cache" -version = "3.7.0" +version = "3.7.1" dependencies = [ {org = "ballerina", name = "constraint"}, {org = "ballerina", name = "jballerina.java"}, @@ -70,7 +70,7 @@ modules = [ [[package]] org = "ballerina" name = "http" -version = "2.10.4" +version = "2.10.7" dependencies = [ {org = "ballerina", name = "auth"}, {org = "ballerina", name = "cache"}, @@ -273,7 +273,7 @@ dependencies = [ [[package]] org = "ballerina" name = "observe" -version = "1.2.0" +version = "1.2.2" dependencies = [ {org = "ballerina", name = "jballerina.java"} ] diff --git a/runtime/config-deployer-service/ballerina/modules/model/GraphQLRoute.bal b/runtime/config-deployer-service/ballerina/modules/model/GraphQLRoute.bal index e471cefac..3b646b091 100644 --- a/runtime/config-deployer-service/ballerina/modules/model/GraphQLRoute.bal +++ b/runtime/config-deployer-service/ballerina/modules/model/GraphQLRoute.bal @@ -34,7 +34,7 @@ public type GQLRouteMatch record { string path; }; -public type GQLType "QUERY"|"MUTATION"; +public type GQLType "QUERY"|"MUTATION"|"SUBSCRIPTION"; public isolated function getGQLRouteMatch(string routeMatch) returns GQLType? { match routeMatch { @@ -43,7 +43,10 @@ public isolated function getGQLRouteMatch(string routeMatch) returns GQLType? { } "MUTATION" => { return "MUTATION"; - } //TODO: add SUBSCRIPTION when support is added + } + "SUBSCRIPTION" => { + return "SUBSCRIPTION"; + } _ => { return; // Returns `nil` for unmatched cases } 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 1e068f0c7..9aa4dfc57 100644 --- a/test/cucumber-tests/src/test/resources/tests/api/GraphQL.feature +++ b/test/cucumber-tests/src/test/resources/tests/api/GraphQL.feature @@ -19,7 +19,7 @@ Feature: Generating APK conf for GraphQL API When I use the APK Conf file "artifacts/apk-confs/graphql/graphql_conf_with_sub.apk-conf" And the definition file "artifacts/definitions/graphql_sample_api.graphql" And make the API deployment request - Then the response status code should be 500 + Then the response status code should be 200 Scenario: Generating APK conf using an invalid GraphQL API definition Given The system is ready