ballerina-platform / ballerina-library

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

NPE when Trying to Generate a Client #6435

Open ThisaruGuruge opened 1 year ago

ThisaruGuruge commented 1 year ago

Description: Tried to generate a client for a Ballerina GraphQL sample and it resulted in an NPE.

Steps to reproduce:

This will throw the following error:

ballerina: Oh no, something really went wrong. Bad. Sad.

We appreciate it if you can report the code that broke Ballerina in
https://github.com/ballerina-platform/ballerina-lang/issues with the
log you get below and your sample code.

We thank you for helping make us better.

[2023-06-16 15:04:20,741] SEVERE {b7a.log.crash} - null 
java.lang.NullPointerException
        at io.ballerina.graphql.generator.ballerina.TypesGenerator.handleField(TypesGenerator.java:287)
        at io.ballerina.graphql.generator.ballerina.TypesGenerator.handleSelection(TypesGenerator.java:246)
        at io.ballerina.graphql.generator.ballerina.TypesGenerator.addQueryResponseRecords(TypesGenerator.java:198)
        at io.ballerina.graphql.generator.ballerina.TypesGenerator.generateSyntaxTree(TypesGenerator.java:135)
        at io.ballerina.graphql.generator.ballerina.TypesGenerator.generateSrc(TypesGenerator.java:115)
        at io.ballerina.graphql.generator.CodeGenerator.generateTypes(CodeGenerator.java:139)
        at io.ballerina.graphql.generator.CodeGenerator.generateBalSources(CodeGenerator.java:101)
        at io.ballerina.graphql.generator.CodeGenerator.generate(CodeGenerator.java:69)
        at io.ballerina.graphql.cmd.GraphqlCmd.generateClient(GraphqlCmd.java:214)
        at io.ballerina.graphql.cmd.GraphqlCmd.executeOperation(GraphqlCmd.java:188)
        at io.ballerina.graphql.cmd.GraphqlCmd.execute(GraphqlCmd.java:134)
        at java.base/java.util.Optional.ifPresent(Optional.java:183)
        at io.ballerina.cli.launcher.Main.main(Main.java:53)
DimuthuMadushan commented 10 months ago

@ThisaruGuruge The client generation for schema with interfaces is not supported in this version. Since the starwars example included the interface type Character, client generation is failed. There are lot of scenarios that was not handled by the current tool implementation such as https://github.com/ballerina-platform/ballerina-library/issues/6446. This version is support only for the basic scenarios. Created an issue(https://github.com/ballerina-platform/ballerina-library/issues/6383) to track this.

ThisaruGuruge commented 9 months ago

Let's keep the issue in the backlog for now. We can prioritize the issues later.