Enigmatis / graphql-java-annotations

GraphQL Annotations for Java
Other
387 stars 97 forks source link

Detect and fail on overloaded methods #252

Closed shevek closed 1 year ago

shevek commented 4 years ago

The following code is illegal. However, OutputObjectBuilder does not use the definedFields list (could be a set) to detect and fail on the situation. As a result, the schema builds, apparently successfully, but will fail nondeterministically at runtime, depending on which method was returned second by the JDK introspection methods.

public static class Parent {

    @GraphQLNonNull
    @GraphQLField
    public List<Child> getChildren() {
        return Arrays.asList(
                new Child(0),
                new Child(1),
                new Child(2)
        );
    }

    @GraphQLNonNull
    @GraphQLField
    public List<Child> getChildren(@GraphQLName("id") int id) {
        return Arrays.asList(
                new Child(id)
        );
    }
}
shevek commented 4 years ago

Note that we discovered this by porting an application from JDK8 to JDK11.

yarinvak commented 4 years ago

Thanks. I will get into it at some point. If you can PR this it would be helpfull.

Fgerthoffert commented 1 year ago

Hi @shevek ,

We're helping with project maintenance and reviewing the list of opened PRs and Issues.

This issue was created quite a while ago, we were wondering if you were still interested in the outcome, please let us know if this is the case.

Without an answer by July 1st, 2023, this issue will be closed as "inactive" (and can always be re-opened later on if needed).

Thanks,