Skip to content

Commit

Permalink
Merge pull request #2014 from CrowleyRajapakse/graphql
Browse files Browse the repository at this point in the history
Adding changes/fixes related graphql APIs
  • Loading branch information
CrowleyRajapakse authored Feb 21, 2024
2 parents d943cc9 + 4885108 commit 9917b02
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 13 deletions.
1 change: 1 addition & 0 deletions common-go-libs/config/crd/bases/dp.wso2.com_gqlroutes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -872,6 +872,7 @@ spec:
enum:
- QUERY
- MUTATION
- SUBSCRIPTION
type: string
type: object
type: array
Expand Down
1 change: 1 addition & 0 deletions helm-charts/crds/dp.wso2.com_gqlroutes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -873,6 +873,7 @@ spec:
enum:
- QUERY
- MUTATION
- SUBSCRIPTION
type: string
type: object
type: array
Expand Down
6 changes: 3 additions & 3 deletions runtime/config-deployer-service/ballerina/APIClient.bal
Original file line number Diff line number Diff line change
Expand Up @@ -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}};
(<model:HTTPRouteFilter[]>filters).push(apiPolicyFilter);
model:GQLRouteFilter apiPolicyFilter = {extensionRef: {group: "dp.wso2.com", kind: apiPolicyCR.kind, name: apiPolicyCR.metadata.name}};
(<model:GQLRouteFilter[]>filters).push(apiPolicyFilter);
}
}
gqlRouteRules.push(routeRule);
Expand Down Expand Up @@ -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)};
Expand Down
8 changes: 4 additions & 4 deletions runtime/config-deployer-service/ballerina/Dependencies.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
Expand Down Expand Up @@ -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"},
Expand Down Expand Up @@ -273,7 +273,7 @@ dependencies = [
[[package]]
org = "ballerina"
name = "observe"
version = "1.2.0"
version = "1.2.2"
dependencies = [
{org = "ballerina", name = "jballerina.java"}
]
Expand Down Expand Up @@ -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"},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
Expand Down Expand Up @@ -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"},
Expand Down Expand Up @@ -273,7 +273,7 @@ dependencies = [
[[package]]
org = "ballerina"
name = "observe"
version = "1.2.0"
version = "1.2.2"
dependencies = [
{org = "ballerina", name = "jballerina.java"}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9917b02

Please sign in to comment.