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

[Improvement]: Need to Access the Included Types of a Given Type #43151

Open
ThisaruGuruge opened this issue Jul 22, 2024 · 0 comments
Open

[Improvement]: Need to Access the Included Types of a Given Type #43151

ThisaruGuruge opened this issue Jul 22, 2024 · 0 comments
Labels
Team/jBallerina All the issues related to BIR, JVM backend code generation and runtime Type/Improvement

Comments

@ThisaruGuruge
Copy link
Member

Description

We need a way to access the types of a given module to find the included types of a particular type.

Describe your problem(s)

In Ballerina GraphQL package, we have a requirement to find the GraphQL interfaces and the types that implement those interfaces. Consider the following code:

import ballerina/graphql;

service on new graphql:Listener(9090) {
	resource function get profile() returns Profile {
        // ...
    }
}

type Profile distinct service object {
    resource function get name() returns string;
    resource function get age() returns int;
};

service class Student {
    *Profile;

    resource function get name() returns string {
        return "";
    }

    resource function get age() returns int {
        return 20;
    }

    resource function get gpa() returns decimal {
        return 3.8;
    }
}

service class Teacher {
    *Profile;

    resource function get name() returns string {
        return "";
    }

    resource function get age() returns int {
        return 20;
    }

    resource function get subject() returns string {
        return "Physics";
    }
}

When the above GraphQL service is created, we iterate the service to find the types defined in the GraphQL service. In this case, we find the Profile type. When the Profile type is an object type, we need a way to find the other types that included the Profile type; in this case the Student and Teacher types.

Describe your solution(s)

It would be great if we have an API from the runtime where we can retrieve all the types that are accessible from the current module, and then find the included types from those types.

In GraphQL's case, we do have the type names from the compile-time, so if we can access this information by providing the type name would be sufficient.

Related area

-> Runtime

Related issue(s) (optional)

No response

Suggested label(s) (optional)

No response

Suggested assignee(s) (optional)

No response

@ThisaruGuruge ThisaruGuruge added Type/Improvement Team/jBallerina All the issues related to BIR, JVM backend code generation and runtime labels Jul 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Team/jBallerina All the issues related to BIR, JVM backend code generation and runtime Type/Improvement
Projects
None yet
Development

No branches or pull requests

1 participant