Skip to content

Commit 8fbcfac

Browse files
committed
Fix listener error when passing configurables as init parameters
1 parent 04cfa43 commit 8fbcfac

File tree

15 files changed

+147
-135
lines changed

15 files changed

+147
-135
lines changed

ballerina-tests/graphql-advanced-test-suite/tests/listeners.bal

+4-1
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,7 @@
1616

1717
import ballerina/graphql;
1818

19-
listener graphql:Listener graphqlListener = new (9090);
19+
configurable int port = 9090;
20+
configurable graphql:ListenerConfiguration graphqlListenerConfigs = {};
21+
22+
listener graphql:Listener graphqlListener = new (port, graphqlListenerConfigs);

ballerina-tests/graphql-interceptor-test-suite/tests/listeners.bal

-1
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,3 @@
1717
import ballerina/graphql;
1818

1919
listener graphql:Listener basicListener = new (9090);
20-
listener graphql:Listener subscriptionListener = new (9091);

ballerina-tests/graphql-service-test-suite/tests/30_graphiql_client.bal

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ function testGraphiqlWithSamePathAsGraphQLService() returns error? {
2626
graphql:Error? result = basicListener.attach(graphiqlConfigService, "ballerina/graphiql");
2727
test:assertTrue(result is graphql:Error);
2828
graphql:Error err = <graphql:Error>result;
29-
test:assertEquals(err.message(), "Error occurred while attaching the GraphiQL endpoint");
29+
test:assertEquals(err.message(), "Error occurred while attaching the HTTP service");
3030
}
3131

3232
@test:Config {

ballerina-tests/graphql-subgraph-test-suite/subgraphs.bal

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ service /subgraph on new graphql:Listener(9088) {
2121
resource function get greet() returns string => "welcome";
2222
}
2323

24-
public graphql:Service subgraphServivce = @subgraph:Subgraph service object {
24+
public graphql:Service subgraphService = @subgraph:Subgraph service object {
2525
resource function get greeting() returns string => "welcome";
2626
};
2727

ballerina-tests/graphql-subgraph-test-suite/tests/01_subgraph_tests.bal

+4-2
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,15 @@ isolated function testQueringSdlOnSubgraph() returns error? {
109109
groups: ["federation", "subgraph"]
110110
}
111111
function testAttachingSubgraphServiceToDynamicListener() returns error? {
112-
check subgraphListener.attach(subgraphServivce, "subgraph");
112+
graphql:Listener subgraphListener = check new (9095);
113+
check subgraphListener.attach(subgraphService, "subgraph");
114+
check subgraphListener.start();
113115
string url = "http://localhost:9095/subgraph";
114116
graphql:Client graphqlClient = check new (url);
115117
string document = check common:getGraphqlDocumentFromFile("querying_entities_field_on_subgraph");
116118
json response = check graphqlClient->execute(document);
117119
json expectedPayload = check common:getJsonContentFromFile("querying_entities_field_on_subgraph");
118-
check subgraphListener.detach(subgraphServivce);
120+
check subgraphListener.detach(subgraphService);
119121
common:assertJsonValuesWithOrder(response, expectedPayload);
120122
}
121123

ballerina-tests/graphql-subgraph-test-suite/tests/listeners.bal

-19
This file was deleted.

ballerina-tests/graphql-subscription-test-suite/modules/five/tests/01_subscription_five_tests.bal

+4-2
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,20 @@
1616

1717
import ballerina/graphql;
1818
import ballerina/graphql_test_common as common;
19+
import ballerina/http;
1920
import ballerina/test;
2021
import ballerina/websocket;
2122

2223
@test:Config {
2324
groups: ["listener", "subscriptions"]
2425
}
2526
function testAttachServiceWithSubscriptionToHttp2BasedListener() returns error? {
27+
http:Listener http2Listener = check new http:Listener(9090);
28+
graphql:Listener http2BasedListener = check new (http2Listener);
2629
graphql:Error? result = http2BasedListener.attach(subscriptionService);
2730
test:assertTrue(result is graphql:Error);
2831
graphql:Error err = <graphql:Error>result;
29-
string expectedMessage = string `Websocket listener initialization failed due to the incompatibility of ` +
30-
string `provided HTTP(version 2.0) listener`;
32+
string expectedMessage = "GraphQL subscriptions are only supported over HTTP/1.1 or HTTP/1.0. Found 2.0";
3133
test:assertEquals(err.message(), expectedMessage);
3234
}
3335

ballerina-tests/graphql-subscription-test-suite/modules/five/tests/listeners.bal

-4
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,5 @@
1515
// under the License.
1616

1717
import ballerina/graphql;
18-
import ballerina/http;
19-
20-
listener http:Listener http2Listener = new http:Listener(9090);
21-
listener graphql:Listener http2BasedListener = new (http2Listener);
2218

2319
listener graphql:Listener subscriptionListener = new (9091);

ballerina-tests/graphql-subscription-test-suite/modules/six/tests/listeners.bal

-1
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,4 @@
1616

1717
import ballerina/graphql;
1818

19-
listener graphql:Listener basicListener = new (9090);
2019
listener graphql:Listener subscriptionListener = new (9091);

ballerina/annotation_processor.bal

-30
Original file line numberDiff line numberDiff line change
@@ -59,20 +59,6 @@ isolated function getServiceInterceptors(GraphqlServiceConfig? serviceConfig) re
5959
return [];
6060
}
6161

62-
isolated function getIntrospection(GraphqlServiceConfig? serviceConfig) returns boolean {
63-
if serviceConfig is GraphqlServiceConfig {
64-
return serviceConfig.introspection;
65-
}
66-
return true;
67-
}
68-
69-
isolated function getValidation(GraphqlServiceConfig? serviceConfig) returns boolean {
70-
if serviceConfig is GraphqlServiceConfig {
71-
return serviceConfig.validation;
72-
}
73-
return true;
74-
}
75-
7662
isolated function getFieldInterceptors(service object {} serviceObj, parser:RootOperationType operationType,
7763
string fieldName, string[] resourcePath) returns readonly & (readonly & Interceptor)[] {
7864
GraphqlResourceConfig? resourceConfig = getResourceAnnotation(serviceObj, operationType, resourcePath, fieldName);
@@ -109,22 +95,6 @@ isolated function getInterceptorConfig(readonly & Interceptor interceptor) retur
10995
return classType.@InterceptorConfig;
11096
}
11197

112-
isolated function getCacheConfig(GraphqlServiceConfig? serviceConfig) returns ServerCacheConfig? {
113-
if serviceConfig is GraphqlServiceConfig {
114-
if serviceConfig.cacheConfig is ServerCacheConfig {
115-
return serviceConfig.cacheConfig;
116-
}
117-
}
118-
return;
119-
}
120-
121-
isolated function getFieldCacheConfigFromServiceConfig(GraphqlServiceConfig? serviceConfig) returns ServerCacheConfig? {
122-
if serviceConfig is GraphqlServiceConfig {
123-
return serviceConfig.fieldCacheConfig;
124-
}
125-
return;
126-
}
127-
12898
isolated function getFieldCacheConfig(service object {} serviceObj, parser:RootOperationType operationType,
12999
string fieldName, string[] resourcePath) returns ServerCacheConfig? {
130100
GraphqlResourceConfig? resourceConfig = getResourceAnnotation(serviceObj, operationType, resourcePath, fieldName);

ballerina/build.gradle

+1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ ballerina {
5050
module = packageName
5151
langVersion = ballerinaLangVersion
5252
testCoverageParam = "--code-coverage --coverage-format=xml --includes=io.ballerina.stdlib.graphql.*:ballerina.graphql*"
53+
platform = 'java21'
5354
}
5455

5556
task updateTomlFiles {

0 commit comments

Comments
 (0)