ballerina-platform / ballerina-library

The Ballerina Library
https://ballerina.io/learn/api-docs/ballerina/
Apache License 2.0
137 stars 61 forks source link

Validate Structurally Equal Record Types as Different Types in GraphQL Input Objects #1844

Open DimuthuMadushan opened 3 years ago

DimuthuMadushan commented 3 years ago

Description: Consider the following GraphQL service:

type AddressI record {
    int number;
    string street;
    string city;
};

type AddressO record {
    int number;
    string street;
    string city;
};

type Person record {
    string name;
    int age;
    AddressO address;
};

service on new graphql:Listener(9000) {
    resource function get name(AddressI address) returns Person {
        return {
            name: "Walter",
            age: 51,
            address: {
                number: 308,
                street: "Negra Arroyo Lane",
                city: "Albequerqy"
            }
        };
    }
}

Since AddressI and AddressO are defined separatetly, this should be a valid service. It needs to differentiate the AddressI in the function input parameter and the AddressO in the function return type Person at the compile plugging. Currently we can not validate this due to absence of distinct type for ballerina records.

ThisaruGuruge commented 1 year ago

Closing as this is no further valid

ThisaruGuruge commented 1 year ago

Re-opening this as this issue still occurs.

ThisaruGuruge commented 1 year ago

Maybe we can do this if the lang supports distinct record types.