graphql-java-generator / graphql-maven-plugin-project

graphql-maven-plugin is a Maven Plugin for GraphQL, based on graphql-java. It accelerates the development for both the client and the server, by generating the Java code. It allows a quicker development when in contract-first approach, by avoiding to code the boilerplate code.
https://graphql-maven-plugin-project.graphql-java-generator.com
MIT License
115 stars 47 forks source link

Java method and params Naming conventions in @GraphQLRepository #204

Closed andreikrutsko closed 7 months ago

andreikrutsko commented 7 months ago

Actually Not an issue at all... Nice to have feature request

Pls correct me if I'm wrong. If we have an method endpoint in GraphQL schema like "some_method_name( some_param: Type ): [SomeType!]!" via underscores . Have we to specify exactly the same "some_method_name(T some_param)" in repo @GraphQLRepository? Is that correct? I've tried any other options and checked implementation and seems like it is not and the only exact "some_method_name(T some_param)" allowed, am I right? The thing is that according to name conventions and validators like SonarQube/SonarLint "Shared naming conventions allow teams to collaborate efficiently. This rule raises an issue when a method name does not match a provided regular expression. For example, with the default provided regular expression ^[a-z][a-zA-Z0-9]*$, the method". In another words underscores are not allowed and instead of "some_method_name(T some_param)" it must be "someMethodName(T someParam)". So methods in repo are highlighted by SonarLint validator against java:S100 rule. Absolutely not critical, but you know... if might be better :)

Is there any possible way to implement in any lower priority annotations and add an option to annotate such methods like:

@BindParameter(name = "some_method_name")
someMethodName(@BindParameter(name = "some_param") T someParam)

or any similar approach to avoid using underscores in java naming even if they are used and specified in GraphQL schema? That would be very usefull to bind repos names to interfaces and in Java link with proper naming.

etienne-sf commented 7 months ago

Hello,

Have we to specify exactly the same "some_method_name(T some_param)" in repo @GraphQLRepository?

Actually no. This question refers only to partial requests, as the full request's request parameter contains all the needed information.

For partial request, the optional ´requestName´ parameter for the ´@PartialRequest´ annotation allows you to provide the method name, as you call it. Then the actual method in the GraphQL repository is free.

Étienne