Skip to content

Invalid generated Java source code for GraphQL interfaces with disabled generateParameterizedFieldsResolvers #976

@Syquel

Description

@Syquel

Issue Description

The Gradle plugin graphql-java-codegen produces invalid Java source code for GraphQL types which implement an interface if the option generateParameterizedFieldsResolvers is disabled.

This bug might have been introduced by #913 .

Steps to Reproduce

GraphQL:

interface A {
    foo(arg: String): String
}

type B implements A {
    foo(arg: String): String
}

Expected Result

The Java interface A and class B should have a method String getFoo() without parameters.

A.java

public interface A {
    String getFoo();
}

B.java

public class B implements java.io.Serializable, A {

    private static final long serialVersionUID = 1L;

    private String foo;

    public B() {
    }

    public B(String foo) {
        this.foo = foo;
    }

    public String getFoo() {
        return foo;
    }
    public void setFoo(String foo) {
        this.foo = foo;
    }

    [...]
}

Actual Result

The Java interface A has a method String getFoo(String arg) with a parameter while the Java class B has a method public String getFoo() * without* parameters.
This prevents class B to be compiled, because the contract of interface A is not fulfilled.

A.java

public interface A {
    String getFoo(String arg);
}

B.java

public class B implements java.io.Serializable, A {

    private static final long serialVersionUID = 1L;

    private String foo;

    public B() {
    }

    public B(String foo) {
        this.foo = foo;
    }

    public String getFoo() {
        return foo;
    }
    public void setFoo(String foo) {
        this.foo = foo;
    }

    [...]
}

Your Environment and Setup

  • graphql-java-codegen version: 5.4.0
  • Build tool: Gradle
  • Mapping Config:
generateApis = false
generateClient = true
generateParameterizedFieldsResolvers = false

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions