Enigmatis / graphql-java-annotations

GraphQL Annotations for Java
Other
387 stars 97 forks source link

Make it possible to provide custom prefixes AND postfixes for input objects #184

Closed sergehuber closed 6 years ago

sergehuber commented 6 years ago

Make it possible to provide custom prefixes AND postfixes for input object name generation. This is setup on the container.

The defaults were not changed and are equivalent to : container.setInputPrefix("Input"); container.setInputPostfix("";

If you want to change the naming generation to something more "compliant" with GraphQL's naming conventions you can change the configuration to:

container.setInputPrefix(""); container.setInputPostfix("Input");

So for example, if generating a name for the input type generated from the class Books it will be called InputBooks in the first configuration and BooksInput in the second configuration. This is also very useful if you are using prefixes to namespace your classes. For example, ACMEBooks will be InputACMEBooks in the first configuration and ACMEBooksInput in the second configuration.

As you can see the prefix and postfix configuration is also very flexible and the "Input" word is just a configuration variable now.

By default, however, nothing changes so existing projects should not break.

Some unit tests were also added to make sure that the generation works properly.

Please don't hesitate if you have any questions or comments about this PR, I will do my best to answer swiftly.

yarinvak commented 6 years ago

It looks very nice, thank you. @guy120494 can you look at this also?

guy120494 commented 6 years ago

Looks nice. Only one request: please change "postfix" to "suffix" (I know it's a petty request :) )

sergehuber commented 6 years ago

Actually that change does make sense, I'll do it now.

guy120494 commented 6 years ago

Please resolve the conflict

sergehuber commented 6 years ago

I've just resolved the conflict, I will do the change from postfix to suffix next.

sergehuber commented 6 years ago

Ok I've renamed postfix to suffix. I hope you can accept this PR now :)