Skip to content

Commit

Permalink
change valueOfLabel to valueOf for enum, fix #6320 (#6323)
Browse files Browse the repository at this point in the history
  • Loading branch information
longlho authored Aug 3, 2021
1 parent a89b85a commit 1da66a6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/metal-students-pump.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@graphql-codegen/java': minor
---

revert removal of `valueOfLabel` in Enum generation
2 changes: 1 addition & 1 deletion packages/plugins/java/java/src/visitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ export class JavaResolversVisitor extends BaseVisitor<JavaResolversPluginRawConf
`if (args.get("${arg.name.value}") instanceof ${typeToUse.typeName}) {
this.${this.config.classMembersPrefix}${arg.name.value} = (${typeToUse.typeName}) args.get("${arg.name.value}");
} else {
this.${this.config.classMembersPrefix}${arg.name.value} = ${typeToUse.typeName}.valueOfLabel((String) args.get("${arg.name.value}"));
this.${this.config.classMembersPrefix}${arg.name.value} = ${typeToUse.typeName}.valueOf((String) args.get("${arg.name.value}"));
}`,
3
);
Expand Down
6 changes: 3 additions & 3 deletions packages/plugins/java/java/tests/java.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ describe('Java', () => {
expect(result).toBeSimilarStringTo(`if (args.get("sort") instanceof ResultSort) {
this.sort = (ResultSort) args.get("sort");
} else {
this.sort = ResultSort.valueOfLabel((String) args.get("sort"));
this.sort = ResultSort.valueOf((String) args.get("sort"));
}`);
});

Expand Down Expand Up @@ -274,7 +274,7 @@ describe('Java', () => {
if (args.get("sort") instanceof ResultSort) {
this.sort = (ResultSort) args.get("sort");
} else {
this.sort = ResultSort.valueOfLabel((String) args.get("sort"));
this.sort = ResultSort.valueOf((String) args.get("sort"));
}
this.metadata = new MetadataSearchInput((Map<String, Object>) args.get("metadata"));
}
Expand Down Expand Up @@ -407,7 +407,7 @@ describe('Java', () => {
// expect(result).toBeSimilarStringTo(`if (args.get("sort") instanceof ResultSort) {
// this.sort = (ResultSort) args.get("sort");
// } else {
// this.sort = ResultSort.valueOfLabel((String) args.get("sort"));
// this.sort = ResultSort.valueOf((String) args.get("sort"));
// }`);
// });

Expand Down

0 comments on commit 1da66a6

Please sign in to comment.