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 __typename introspection is crashed when fields return a nullable, union type array #2571

Closed
DimuthuMadushan opened this issue Jan 12, 2022 · 0 comments · Fixed by ballerina-platform/module-ballerina-graphql#565
Assignees
Labels
module/graphql Issues related to Ballerina GraphQL module Points/2 Team/PCM Protocol connector packages related issues Type/Bug

Comments

@DimuthuMadushan
Copy link

Description:
If a GraphQL resource function includes a nullable, union type array as the return type, the __typename for that field can not be resolved properly.
Consider the following GrpahQL service:

import ballerina/graphql;

type Character Human|Droid;

distinct isolated service class Human {
    resource function get name () returns string {
        return "human-1";
    }
}

distinct isolated service class Droid {
    resource function get id () returns string {
        return "droid-1";
    }
}
service /graphql on new graphql:Listener(9090) {
    resource function get character() returns Character?[] {
        return [new Human(), new Droid(), ()];
    }
}

if we query this as follow:

{
    character {
        __typename
    }
}

the result should be:

{
  "data": {
    "character": [
      {
        "__typename": "Human"
      },
      {
        "__typename": "Droid"
      },
      null
    ]
  }
}

Currently, this service is crashed when querying.

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 Points/2 Team/PCM Protocol connector packages related issues Type/Bug
Projects
None yet
2 participants