Closed kewinremy closed 1 year ago
Thanks for this PR.
You're right, there is an issue here : I created IT test to check that, to check that your PR actually solve the issue I've identifier from your PR.
I'll probably update the code, then, as the field generated by the plugin contain a @GraphQLScalar
or @GraphQLNonScalar
annotation, that allows to get the real name for the GraphQL field, as defined in the GraphQL schema.
Etienne
BTW, I confirm we're talking about the same issue: once I checked out your PR, my IT test stops complaining about the lack of the getter method.
Hello Remy,
I have a question on the change you did:
// For the boolean fields, the getter may be named isProperty. Let's try that:
if (field.getType().equals(boolean.class) || field.getType().equals(Boolean.class) && field.getName().startsWith("is")) {
getterMethodName = "is" + getPascalCase(field.getName());
method = clazz.getMethod(getterMethodName);
}
// For the fields conflicting with reserved keywords and generated with an underscore (_), the getter may be named _Property. Let's try that:
else if (field.getName().startsWith("_")) {
String sanitizedField = field.getName().substring(1);
getterMethodName = "get" + getPascalCase(sanitizedField);
method = clazz.getMethod(getterMethodName);
} else {
throw e;
}
In the first if
, there is this command: field.getName().startsWith("is")
I don't understand the reason which why you check if the field starts by is
.
Can you precise that?
Etienne
At runtime, the getGetter method does not support reserved keywords like default, etc. Currently it sends the "NoSuchMethodException" at runtime when properly fields are about to be serialized.
For complete information, please have a look at my comment on a previous PR: https://github.com/graphql-java-generator/graphql-maven-plugin-project/issues/166
Version affected: 1.18.9
pom.xml