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

Open
TharmiganK opened this issue Jan 16, 2025 · 0 comments
Open
Assignees
Labels
module/graphql Issues related to Ballerina GraphQL module 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

@TharmiganK TharmiganK added module/graphql Issues related to Ballerina GraphQL module Type/Bug labels Jan 16, 2025
@ThisaruGuruge ThisaruGuruge self-assigned this Jan 28, 2025
@ThisaruGuruge ThisaruGuruge moved this from BackLog to In Progress in Ballerina Team Main Board Jan 28, 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 Type/Bug
Projects
Status: In Progress
Development

No branches or pull requests

2 participants