Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot make the graphql:ListenerConfiguration as a configurable variable #7502

Closed
TharmiganK opened this issue Jan 16, 2025 · 1 comment · Fixed by ballerina-platform/module-ballerina-graphql#2147
Assignees
Labels
module/graphql Issues related to Ballerina GraphQL module Reason/EngineeringMistake The issue occurred due to a mistake made in the past. Type/Bug

Comments

@TharmiganK
Copy link
Contributor

Description

When I try to make the graphql:ListenerConfiguration record value as a configurable. The program fails at runtime

Steps to Reproduce

Run the following Ballerina code:

import ballerina/graphql;

# Represents the default GraphQL port. Default value is 9092
public configurable int graphqlPort = 9092;

# Represents the default GraphQL listener configurations
public configurable graphql:ListenerConfiguration graphqlListenerConfigs = {};

# Represents a GraphQL listener that can be used by multiple services
public listener graphql:Listener graphqlListener = new(graphqlPort, graphqlListenerConfigs);

service /graphql on graphqlListener {
    resource function get greeting() returns string {
        return "Hello, World";
    }
}

Runtime error:

error: {ballerina/lang.map}InherentTypeViolation {"message":"cannot update 'readonly' field 'httpVersion' in record of type '(graphql:ListenerConfiguration & readonly)'"}
        at ballerina.graphql.1.Listener:init(listener.bal:41)

This is because we are trying to overwrite the httpVersion in the listener init function - https://github.com/ballerina-platform/module-ballerina-graphql/blob/73ddff7b7627eed9f263ddeb88dc6a3144c80c28/ballerina/listener.bal#L41 which fails for values from configurable variable since the value is readonly.

Version

Ballerina Swan Lake Update 10

Environment Details (with versions)

No response

Copy link

This issue is NOT closed with a proper Reason/ label. Make sure to add proper reason label before closing. Please add or leave a comment with the proper reason label now.

      - Reason/EngineeringMistake - The issue occurred due to a mistake made in the past.
      - Reason/Regression - The issue has introduced a regression.
      - Reason/MultipleComponentInteraction - Issue occured due to interactions in multiple components.
      - Reason/Complex - Issue occurred due to complex scenario.
      - Reason/Invalid - Issue is invalid.
      - Reason/Other - None of the above cases.

@ThisaruGuruge ThisaruGuruge added the Reason/EngineeringMistake The issue occurred due to a mistake made in the past. label Jan 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module/graphql Issues related to Ballerina GraphQL module Reason/EngineeringMistake The issue occurred due to a mistake made in the past. Type/Bug
Projects
Status: Done
2 participants