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

Empty Values Returned when Fragment is Used Inside Another Fragment to Query a Service Object #1447

Closed
ThisaruGuruge opened this issue Jun 10, 2021 · 0 comments · Fixed by ballerina-platform/module-ballerina-graphql#281
Assignees
Labels
module/graphql Issues related to Ballerina GraphQL module Team/PCM Protocol connector packages related issues Type/Bug

Comments

@ThisaruGuruge
Copy link
Member

Description:
Consider the following scenario:

import ballerina/graphql;

service /graphql on new graphql:Listener(9000) {
    resource function get teacher() returns Teacher {
        return new (737, "Walter White", "Chemistry");
    }
}

distinct service class Teacher {
    private int id;
    private string name;
    private string subject;

    public isolated function init(int id, string name, string subject) {
        self.id = id;
        self.name = name;
        self.subject = subject;
    }

    isolated resource function get id() returns int {
        return self.id;
    }

    isolated resource function get name() returns string {
        return self.name;
    }

    isolated resource function get subject() returns string {
        return self.subject;
    }
}

When querying this using the following document:

query {
    ... QueryFragment
}

fragment QueryFragment on Query {
     teacher {
         ...TeacherFragment
     }
}

fragment TeacherFragment on Teacher {
    ...NameFragment
}

fragment NameFragment on Teacher {
    name
}

The result is the following:

{
    "data": {
        "teacher": {}
    }
}

Expected result:

{
    "data": {
        "teacher": {
            "name": "Walter White"
        }
    }
}
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 Team/PCM Protocol connector packages related issues Type/Bug
Projects
None yet
1 participant