You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In version 1.7, generating code for this example (based on example No 62 from the spec), will result in an error:
interfaceNamedEntity {
# an awesome name!name: String
}
typePersonimplementsNamedEntity {
name: String # age in yearsage: Int
}
Expected Result
The code is generated correctly
Actual Result
An error occurrs during compilation:
Error:(8,20) java: variable name is already defined in class com.example.Person
Error:(13,52) java: variable name is already defined in constructor Person(java.lang.String,java.lang.Integer,java.lang.String)
Error:(42,19) java: method getName() is already defined in class com.example.Person
Error:(48,17) java: method setName(java.lang.String) is already defined in class com.example.Person
Error:(58,24) java: variable name is already defined in class com.example.Person.Builder
Error:(79,24) java: method setName(java.lang.String) is already defined in class com.example.Person.Builder
The generated code is:
NamedEntity.java
packagecom.example.api;
publicinterfaceNamedEntity {
/** * an awesome name! */StringgetName();
}
Person.java Note that name is generated twice because of the comment in the interface.
If I remove the comment in the interface, it works fine.
packagecom.example.api;
publicclassPersonimplementsNamedEntity{
privateStringname;
privateIntegerage;
privateStringname;
publicPerson() {
}
publicPerson(Stringname, Integerage, Stringname) {
this.name = name;
this.age = age;
this.name = name;
}
publicStringgetName() {
returnname;
}
publicvoidsetName(Stringname) {
this.name = name;
}
/** * age in years */publicIntegergetAge() {
returnage;
}
/** * age in years */publicvoidsetAge(Integerage) {
this.age = age;
}
/** * an awesome name! */publicStringgetName() {
returnname;
}
/** * an awesome name! */publicvoidsetName(Stringname) {
this.name = name;
}
publicstaticclassBuilder {
privateStringname;
privateIntegerage;
privateStringname;
publicBuilder() {
}
publicBuildersetName(Stringname) {
this.name = name;
returnthis;
}
/** * age in years */publicBuildersetAge(Integerage) {
this.age = age;
returnthis;
}
/** * an awesome name! */publicBuildersetName(Stringname) {
this.name = name;
returnthis;
}
publicPersonbuild() {
returnnewPerson(name, age, name);
}
}
}
Your Environment and Setup
graphql-java-codegen: 1.7.0
Build tool: Maven
Java tool: openjdk 11.0.6 2020-01-14
Mapping Config: It won't tell you much. It's just the paths config
* Handle duplicate fields from the type and interface #128
* Take annotations and javadoc from the type and not the interface #128
* Refactor and add some unit tests
* Simplify the code in TypeDefinitionToDataModelMapper #130
Issue Description
In version 1.7, generating code for this example (based on example No 62 from the spec), will result in an error:
Expected Result
The code is generated correctly
Actual Result
An error occurrs during compilation:
The generated code is:
NamedEntity.java
Person.java
Note that
name
is generated twice because of the comment in the interface.If I remove the comment in the interface, it works fine.
Your Environment and Setup
Additional context
It works with 1.6.0
The text was updated successfully, but these errors were encountered: