Skip to content

Commit

Permalink
Fix Code Coverage Showing Invalid Values with GraphQL Compiler Plugin
Browse files Browse the repository at this point in the history
* Fix invalid code coverage values from graphql compiler plugin

* Apply suggestions from code review
  • Loading branch information
ThisaruGuruge committed Apr 25, 2024
1 parent ee542a9 commit 05b245c
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 14 deletions.
2 changes: 1 addition & 1 deletion ballerina-tests/Dependencies.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

[ballerina]
dependencies-toml-version = "2"
distribution-version = "2201.9.0-20240405-165800-4b163f78"
distribution-version = "2201.9.0-20240410-095500-2653a74d"

[[package]]
org = "ballerina"
Expand Down
2 changes: 1 addition & 1 deletion ballerina/Dependencies.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

[ballerina]
dependencies-toml-version = "2"
distribution-version = "2201.9.0-20240405-165800-4b163f78"
distribution-version = "2201.9.0-20240410-095500-2653a74d"

[[package]]
org = "ballerina"
Expand Down
6 changes: 3 additions & 3 deletions ballerina/modules/dataloader/dataloader.bal
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@ public isolated class DefaultDataLoader {
private final BatchLoadFunction batchFunction;

# Initializes the DataLoader with the given batch function.
#
#
# + loadFunction - The batch function to be used
public isolated function init(BatchLoadFunction loadFunction) {
self.batchFunction = loadFunction;
}

# Collects a key to perform a batch operation at a later time.
#
#
# + key - The key to load later
public isolated function add(anydata key) {
readonly & anydata clonedKey = key.cloneReadOnly();
Expand All @@ -70,7 +70,7 @@ public isolated class DefaultDataLoader {
}

# Retrieves the result for a particular key.
#
#
# + key - The key to retrieve the result
# + 'type - The type of the result
# + return - The result for the key on success, error on failure
Expand Down
2 changes: 2 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
### 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)
- [[#6418] Fix Code Coverage Showing Invalid Entries with GraphQL](https://github.com/ballerina-platform/ballerina-library/issues/6418)
- [[#6310] Fix Incorrect Error Message in Compiler Plugin](https://github.com/ballerina-platform/ballerina-library/issues/6310)

## [1.11.0] - 2023-02-21

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ public enum DiagnosticMessage {
ERROR_113("a GraphQL service must include at least one resource method with the accessor '''"
+ RESOURCE_FUNCTION_GET + "''' that does not have the @dataloader:Loader annotation attached"
+ " to it"),
ERROR_114("the GraphQL field ''{0}'' use input type ''{1}'' as an output type. A GraphQL field cannot use an input "
+ "type as an output type"),
ERROR_115("the GraphQL field ''{0}'' use output type ''{1}'' as an input type. A GraphQL field cannot use an output"
+ " type as an input type"),
ERROR_114("the GraphQL field ''{0}'' uses input type ''{1}'' as an output type. A GraphQL field cannot use an " +
"input type as an output type"),
ERROR_115("the GraphQL field ''{0}'' uses output type ''{1}'' as an input type. A GraphQL field cannot use an " +
"output type as an input type"),
ERROR_116("non-distinct service class ''{0}'' is used as a GraphQL interface"),
ERROR_117("found path parameters ''{0}'' in GraphQL resource. Path parameters are not allowed in GraphQL "
+ "resources"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -431,9 +431,7 @@ private AnnotationNode updateAnnotationNode(AnnotationNode annotationNode, Strin
SeparatedNodeList<MappingFieldNode> updatedFields =
getUpdatedFields(annotationNode.annotValue().get(), schemaString, cacheConfigContext);
MappingConstructorExpressionNode node =
NodeFactory.createMappingConstructorExpressionNode(
NodeFactory.createToken(SyntaxKind.OPEN_BRACE_TOKEN), updatedFields,
NodeFactory.createToken(SyntaxKind.CLOSE_BRACE_TOKEN));
annotationNode.annotValue().get().modify().withFields(updatedFields).apply();
return annotationNode.modify().withAnnotValue(node).apply();
}
return getServiceAnnotation(schemaString, cacheConfigContext, prefix);
Expand All @@ -445,8 +443,14 @@ private SeparatedNodeList<MappingFieldNode> getUpdatedFields(MappingConstructorE
List<Node> fields = new ArrayList<>();
SeparatedNodeList<MappingFieldNode> existingFields = annotationValue.fields();
Token separator = NodeFactory.createToken(SyntaxKind.COMMA_TOKEN);
for (MappingFieldNode field : existingFields) {
fields.add(field);
int fieldCount = existingFields.size();
for (int i = 0; i < fieldCount; i++) {
fields.add(existingFields.get(i));
if (fieldCount > 1 && i < fieldCount - 1) {
fields.add(existingFields.getSeparator(i));
}
}
if (fieldCount > 0) {
fields.add(separator);
}
fields.add(getSchemaStringFieldNode(schemaString));
Expand Down

0 comments on commit 05b245c

Please sign in to comment.