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

GraphQL Resolvers Cannot Return Error Reference Types #4848

Closed
ThisaruGuruge opened this issue Sep 26, 2023 · 0 comments · Fixed by ballerina-platform/module-ballerina-graphql#1794
Assignees
Labels
Good first issue Good for newcomers module/graphql Issues related to Ballerina GraphQL module Reason/EngineeringMistake The issue occurred due to a mistake made in the past. Type/Bug
Milestone

Comments

@ThisaruGuruge
Copy link
Member

Description:
GraphQL resolver functions (resource/remote) methods should be able to return custom error types. Currently, when you return a custom error, the compiler plugin throws an error.

Consider the following code:

import ballerina/graphql;

service on new graphql:Listener(9090) {
    resource function get greeting() string|graphql:Error {
        return error graphql:Error("Error");
    }
}

The above code does not compile and returns the following compilation error:

ERROR [main.bal:(9:5,14:6)] invalid GraphQL union type member 'string' found. Only distinct service types are allowed
ERROR [main.bal:(9:5,14:6)] invalid GraphQL union type member 'Error' found. Only distinct service types are allowed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Good first issue Good for newcomers module/graphql Issues related to Ballerina GraphQL module Reason/EngineeringMistake The issue occurred due to a mistake made in the past. Type/Bug
Projects
Archived in project
2 participants