-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Support to Generate GraphQL Schema for Local Service Variable Dec…
…laration (#1704) * [Automated] Update the native jar versions * [Automated] Update the native jar versions * Add support to gen schema from local service obj * Update changelog * Add copyright and license * Update license header * Apply suggestions from code reviews * [Automated] Update the native jar versions * [Automated] Update the native jar versions * Use textRange to modify service declaration nodes * Add support to generate schema for object field * Remove unused test case resources * Add test case with distinct service class type * Apply suggestions from code review * [Automated] Update the native jar versions * [Automated] Update the native jar versions * Add runtime tests --------- Co-authored-by: Thisaru Guruge <thisaru@wso2.com>
- Loading branch information
1 parent
49a141c
commit edcb9b1
Showing
18 changed files
with
495 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
...ces/ballerina_sources/generator_tests/25_local_service_object_declarations/Ballerina.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[package] | ||
org = "graphql_test" | ||
name = "test_package" | ||
version = "0.1.0" |
39 changes: 39 additions & 0 deletions
39
...ources/ballerina_sources/generator_tests/25_local_service_object_declarations/service.bal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Copyright (c) 2024 WSO2 LLC. (http://www.wso2.com) All Rights Reserved. | ||
// | ||
// WSO2 LLC. licenses this file to you under the Apache License, | ||
// Version 2.0 (the "License"); you may not use this file except | ||
// in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
|
||
import ballerina/lang.runtime; | ||
import ballerina/graphql; | ||
|
||
public function main() returns error? { | ||
graphql:Service localService1 = service object { | ||
resource function get greeting() returns string { | ||
return "Hello from local service 1"; | ||
} | ||
}; | ||
graphql:Service localService2 = service object { | ||
resource function get greeting() returns string { | ||
return "Hello from local service 1"; | ||
} | ||
}; | ||
graphql:Listener localListener1 = check new(9090); | ||
graphql:Listener localListener2 = check new(9091); | ||
check localListener1.attach(localService1); | ||
check localListener2.attach(localService2); | ||
check localListener1.'start(); | ||
check localListener2.'start(); | ||
runtime:registerListener(localListener1); | ||
runtime:registerListener(localListener2); | ||
} |
4 changes: 4 additions & 0 deletions
4
...lerina_sources/generator_tests/26_object_field_service_object_declarations/Ballerina.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[package] | ||
org = "graphql_test" | ||
name = "test_package" | ||
version = "0.1.0" |
49 changes: 49 additions & 0 deletions
49
...ballerina_sources/generator_tests/26_object_field_service_object_declarations/service.bal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// Copyright (c) 2024 WSO2 LLC. (http://www.wso2.com) All Rights Reserved. | ||
// | ||
// WSO2 LLC. licenses this file to you under the Apache License, | ||
// Version 2.0 (the "License"); you may not use this file except | ||
// in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
|
||
import ballerina/lang.runtime; | ||
import ballerina/graphql; | ||
|
||
class TestService { | ||
private graphql:Service fieldService1 = service object { | ||
resource function get greeting() returns string { | ||
return "Hello from object field service object 1"; | ||
} | ||
}; | ||
private graphql:Service fieldService2 = service object { | ||
resource function get greeting() returns string { | ||
return "Hello from object field service object 2"; | ||
} | ||
}; | ||
|
||
public function init() {} | ||
|
||
public function startService() returns error? { | ||
graphql:Listener localListener1 = check new(9090); | ||
graphql:Listener localListener2 = check new(9091); | ||
check localListener1.attach(self.fieldService1); | ||
check localListener2.attach(self.fieldService2); | ||
check localListener1.'start(); | ||
check localListener2.'start(); | ||
runtime:registerListener(localListener1); | ||
runtime:registerListener(localListener2); | ||
} | ||
} | ||
|
||
public function main() returns error? { | ||
TestService serviceClass = new (); | ||
check serviceClass.startService(); | ||
} |
4 changes: 4 additions & 0 deletions
4
...resources/ballerina_sources/generator_tests/27_inline_service_declarations/Ballerina.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[package] | ||
org = "graphql_test" | ||
name = "test_package" | ||
version = "0.1.0" |
17 changes: 17 additions & 0 deletions
17
...st/resources/ballerina_sources/generator_tests/27_inline_service_declarations/service.bal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Copyright (c) 2024 WSO2 LLC. (http://www.wso2.com) All Rights Reserved. | ||
// | ||
// WSO2 LLC. licenses this file to you under the Apache License, | ||
// Version 2.0 (the "License"); you may not use this file except | ||
// in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
|
||
import ballerina/lang.runtime; import ballerina/graphql; import ballerina/http; service / on new http:Listener(9090) { resource function get greet() returns string { return "Hello from global http service"; } } public function main() returns error? { graphql:Service gqlService = service object { resource function get greet() returns string { return "Hello from gql service"; } }; http:Service httpService = service object { resource function get greet() returns string { return "Hello from local http service"; } }; graphql:Listener gqlListener = check new(9091); http:Listener httpListener = check new(9092); check gqlListener.attach(gqlService); check httpListener.attach(httpService); check gqlListener.'start(); check httpListener.'start(); runtime:registerListener(gqlListener); runtime:registerListener(httpListener); } |
4 changes: 4 additions & 0 deletions
4
...rces/ballerina_sources/generator_tests/28_with_distinct_service_class_type/Ballerina.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[package] | ||
org = "graphql_test" | ||
name = "test_package" | ||
version = "0.1.0" |
Oops, something went wrong.