diff --git a/ballerina-tests/Dependencies.toml b/ballerina-tests/Dependencies.toml index b8406312a..b27a3f073 100644 --- a/ballerina-tests/Dependencies.toml +++ b/ballerina-tests/Dependencies.toml @@ -121,7 +121,7 @@ modules = [ [[package]] org = "ballerina" name = "http" -version = "2.10.7" +version = "2.10.12" dependencies = [ {org = "ballerina", name = "auth"}, {org = "ballerina", name = "cache"}, diff --git a/ballerina-tests/tests/31_intersection_types.bal b/ballerina-tests/tests/31_intersection_types.bal index ec5ee2ac4..169ee2f70 100644 --- a/ballerina-tests/tests/31_intersection_types.bal +++ b/ballerina-tests/tests/31_intersection_types.bal @@ -39,6 +39,20 @@ function dataProviderIntersectionType() returns map<[string, string, json]> { } }; + json variableGetOwnerName = { + pet: { + name: "Dingi", + ownerName: "Ruwangi", + animal: { + commonName: "Common House Cat", + species: { + genus: "Felis", + specificName: "catus" + } + } + } + }; + map<[string, string, json]> dataSet = { "1": ["input_with_intersection_parameter", "getName", ()], "2": ["input_with_intersection_parameter_reference", "getCity", ()], @@ -49,7 +63,8 @@ function dataProviderIntersectionType() returns map<[string, string, json]> { "7": ["output_with_intersection_parameter_array", "getProfiles", ()], "8": ["output_with_intersection_parameter_reference_array", "getBooks", ()], "9": ["input_with_intersection_referring_non_intersection_type", "getCommonName", variableGetCommonName], - "10": ["input_with_non_intersection_type_referring_intersection_type", "getOwnerName", ()] + "10": ["input_with_non_intersection_type_referring_intersection_type", "getOwnerName", ()], + "11": ["input_with_non_intersection_type_referring_intersection_type_as_a_variable", "getOwnerNameWithVariable", variableGetOwnerName] }; return dataSet; } diff --git a/ballerina-tests/tests/resources/documents/intersection_types.graphql b/ballerina-tests/tests/resources/documents/intersection_types.graphql index 569f4ef00..4c22e1c94 100644 --- a/ballerina-tests/tests/resources/documents/intersection_types.graphql +++ b/ballerina-tests/tests/resources/documents/intersection_types.graphql @@ -75,3 +75,7 @@ query getOwnerName { } ) } + +query getOwnerNameWithVariable($pet: Pet!) { + ownerName(pet: $pet) +} diff --git a/ballerina-tests/tests/resources/expected_results/input_with_non_intersection_type_referring_intersection_type_as_a_variable.json b/ballerina-tests/tests/resources/expected_results/input_with_non_intersection_type_referring_intersection_type_as_a_variable.json new file mode 100644 index 000000000..e8ddb5cdb --- /dev/null +++ b/ballerina-tests/tests/resources/expected_results/input_with_non_intersection_type_referring_intersection_type_as_a_variable.json @@ -0,0 +1,5 @@ +{ + "data": { + "ownerName": "Ruwangi" + } +} diff --git a/ballerina/Dependencies.toml b/ballerina/Dependencies.toml index 146c3416f..ac139ea19 100644 --- a/ballerina/Dependencies.toml +++ b/ballerina/Dependencies.toml @@ -105,7 +105,7 @@ modules = [ [[package]] org = "ballerina" name = "http" -version = "2.10.7" +version = "2.10.12" dependencies = [ {org = "ballerina", name = "auth"}, {org = "ballerina", name = "cache"}, diff --git a/changelog.md b/changelog.md index 0784c2815..acfe2d931 100644 --- a/changelog.md +++ b/changelog.md @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ## [Unreleased] +### Fixed +- [[#4848] Fix Resolvers not Able to Return Error Reference Types](https://github.com/ballerina-platform/ballerina-library/issues/4848) +- [[#4859] Fix Service Crashing when Intersection Types are Used as Input Objects](https://github.com/ballerina-platform/ballerina-library/issues/4859) + ## [1.11.0] - 2023-02-21 ### Added diff --git a/compiler-plugin-tests/src/test/resources/ballerina_sources/validator_tests/01_valid_return_types/service.bal b/compiler-plugin-tests/src/test/resources/ballerina_sources/validator_tests/01_valid_return_types/service.bal index 67daf3cc4..1e7ce17ec 100644 --- a/compiler-plugin-tests/src/test/resources/ballerina_sources/validator_tests/01_valid_return_types/service.bal +++ b/compiler-plugin-tests/src/test/resources/ballerina_sources/validator_tests/01_valid_return_types/service.bal @@ -20,6 +20,8 @@ type Person record { string name; }; +type Error distinct error; + service graphql:Service on new graphql:Listener(4000) { resource function get greeting() returns string { return "Hello"; @@ -74,6 +76,18 @@ service graphql:Service on new graphql:Listener(4000) { } } +service graphql:Service on new graphql:Listener(4000) { + resource function get profile() returns Person|Error { + return {name: "John"}; + } +} + +service graphql:Service on new graphql:Listener(4000) { + resource function get profile() returns Person|graphql:Error { + return {name: "John"}; + } +} + service graphql:Service on new graphql:Listener(4000) { resource function get greet() returns GeneralGreeting { return new; diff --git a/compiler-plugin/src/main/java/io/ballerina/stdlib/graphql/compiler/Utils.java b/compiler-plugin/src/main/java/io/ballerina/stdlib/graphql/compiler/Utils.java index f5b376e34..eee09c51b 100644 --- a/compiler-plugin/src/main/java/io/ballerina/stdlib/graphql/compiler/Utils.java +++ b/compiler-plugin/src/main/java/io/ballerina/stdlib/graphql/compiler/Utils.java @@ -132,7 +132,13 @@ public static boolean isGraphqlListener(Symbol listenerSymbol) { } public static boolean isIgnoreType(TypeSymbol typeSymbol) { - return typeSymbol.typeKind() == TypeDescKind.NIL || typeSymbol.typeKind() == TypeDescKind.ERROR; + if (typeSymbol.typeKind() == TypeDescKind.NIL || typeSymbol.typeKind() == TypeDescKind.ERROR) { + return true; + } + if (typeSymbol.typeKind() == TypeDescKind.TYPE_REFERENCE) { + return isIgnoreType(((TypeReferenceTypeSymbol) typeSymbol).typeDescriptor()); + } + return false; } public static List getEffectiveTypes(UnionTypeSymbol unionTypeSymbol) { diff --git a/gradle.properties b/gradle.properties index 2c7c3afb1..febf83fb7 100644 --- a/gradle.properties +++ b/gradle.properties @@ -38,7 +38,7 @@ stdlibJwtVersion=2.10.0 stdlibOAuth2Version=2.10.0 # Level 05 -stdlibHttpVersion=2.10.0 +stdlibHttpVersion=2.10.12 # Level 06 stdlibWebsocketVersion=2.10.0 diff --git a/native/src/main/java/io/ballerina/stdlib/graphql/runtime/engine/ArgumentHandler.java b/native/src/main/java/io/ballerina/stdlib/graphql/runtime/engine/ArgumentHandler.java index f8120700b..8892ae5de 100644 --- a/native/src/main/java/io/ballerina/stdlib/graphql/runtime/engine/ArgumentHandler.java +++ b/native/src/main/java/io/ballerina/stdlib/graphql/runtime/engine/ArgumentHandler.java @@ -356,7 +356,7 @@ private BMap getInputObjectArgument(BObject argumentNode, Recor BMap recordValue = recordType.getZeroValue(); if (argumentNode.getBooleanValue(VARIABLE_DEFINITION)) { BMap variablesMap = argumentNode.getMapValue(VARIABLE_VALUE_FIELD); - return JsonUtils.convertJSONToRecord(variablesMap, recordType); + return ValueCreator.createRecordValue(recordType.getPackage(), recordType.getName(), variablesMap); } BArray inputObjectFields = argumentNode.getArrayValue(VALUE_FIELD); for (int i = 0; i < inputObjectFields.size(); i++) {