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

[New Feature]: Introduce an API to obtain initializer method type from ObjectType #40302

Closed
MohamedSabthar opened this issue Apr 25, 2023 · 1 comment · Fixed by #40340
Closed
Assignees
Labels
needTriage The issue has to be inspected and labeled manually Priority/High Team/jBallerina All the issues related to BIR, JVM backend code generation and runtime Type/NewFeature userCategory/Compilation
Milestone

Comments

@MohamedSabthar
Copy link
Member

Description

At present, invoking getMethods() function on the ObjectType produces an array of methods that does not comprise the init method. However, there is a need to obtain access to the init method type of the ObjectType for constructing the service object.

Consider the following class

readonly service class Sort {
    *graphql:Directive;
    Direction direction;

    function init(Direction direction, int data) {
        // ...
    }

    isolated remote function applyOnField(graphql:Context ctx, graphql:Field 'field) 
    returns anydata|error {
       // ...
    }
}

Calling getMethods() on the above class returns an array containing applyOnField method but not the init method.

Describe your problem(s)

We have a requirement in GraphQL module to construct service objects from a given object typedesc. To do that the knowledge of the init method parameter types is necessary to create the relevant object by constructing those values in the native side. Unfortunately, currently there isn't a straightforward approach to create an object from a typedesc.

Describe your solution(s)

I can think of two ways:

  1. Modify the getMethods() function to include the type of the init method in the returned array.
  2. Introduce a new function called getInitializer() that solely returns the methodType of the init method.

Related area

-> Compilation

Related issue(s) (optional)

No response

Suggested label(s) (optional)

No response

Suggested assignee(s) (optional)

No response

@ThisaruGuruge
Copy link
Member

@warunalakshitha @HindujaB Can we prioritize this for the next sprint? A GraphQL feature is waiting on this.

@gabilang gabilang added the Team/jBallerina All the issues related to BIR, JVM backend code generation and runtime label May 2, 2023
@gabilang gabilang added this to the 2201.6.0 milestone May 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needTriage The issue has to be inspected and labeled manually Priority/High Team/jBallerina All the issues related to BIR, JVM backend code generation and runtime Type/NewFeature userCategory/Compilation
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

4 participants