-
Notifications
You must be signed in to change notification settings - Fork 50
Support for prefixes and suffixes on generated java classes #155
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
adding surefire reports
…es-for-java-classes
Fixes a copy/paste error in InterfaceType discovered by the new test.
…-classes Support for prefixes and suffixes on generated java classes
It worked without prefixes/suffies because javaName and name were the same.
I added another commit addressing an issue in server_GraphQLWiring.vm where the javaName was used instead of name. |
I am changing the status to draft until testing of the wiring is complete. Any review feedback would be much appreciated. |
Hello, Thanks for the PR. My global comment is that is is well integrated. FYI, the whole project didn't build on my computer, with failure during the IT tests (the sample projects). But I guess it's due to my crazy antivirus (I use my pro PC), as I checked your branch out in another folder to avoid name collision: the IT tests seem Ok when started from eclipse. There is a point with the Gradle plugin:
Then a detail about the parameter doc:
And, to finish, one word about the integration tests: The IT should test various combination of prefix and suffix. My proposal here is:
Notes :
|
About this specific question : the answer is in my previous mail. It's an integration test, and it will be tested in the allGraphQLCases server sample. |
Hi @etienne-sf Thanks for the detailed feedback. |
It worked without prefixes/suffies because javaName and name were the same.
…lasses This prevents the type prefix to be included in the names af data fetchers, executors, responses, and batch loaders.
…es are used correctly in code generation.
…es are used correctly in code generation.
Hi @etienne-sf I clarified the parameter documentation as suggested, and created a module similar to the pojo samples, verifying the configured prefixes and suffixes used in client and server code generation. I chose not to add complexity to the existing samples by parameterising them with prefixes and suffixes. The test revealed quite a few places in the templates, where I would appreciate it, if you could deal with the gradle plugin. FYI: The IT tests in the samples fails on my machine too, but they also do so on the master branch, so that is unrelated to this PR. |
Hello, I had updates on the antivirus configuration of my computer. I didn't find tests where a client with prefix and suffix executes queries against a server with (different) prefix and suffix). The aim of the allGraphQLCases sample is to test complex stuff (whereas the Forum and StarWars samples are more a demo). So the allGraphQLCases sample should be updated so that both the client and the server have suffix and prefix. And these prefixes and suffixes should be different. Etienne |
So you are OK with that the existing allGraphqlCases client/server modules are changed to use prefix/suffix for the generated classes? |
Yes, please : it's exactly its aim. BTW, I should also merge the template sample into it. Etienne |
…e name to java class.
…graphql type in the client runtime.
…lient and server has prefixes and suffixes
Hi Etienne I added prefixes to allGraphQLCases client and server, which resulted in a lot of changes in the tests. This revealed a few issues in the client, which lacked information on how to map a graphql type to the corresponding java class in the presence of prefixes/suffixes. So I added a new generated file for the client, GraphQLTypeMapping, and updated the client runtime to use. Since allGraphQLCases client/server now uses prefixes/suffixes, there is no longer a need for the prefix-suffix module, that I had added, so I removed that again. Mikkel |
Everything's fine. Great ! Thank you for this job (There are issues with recent version of the JDK: I'll try to correct that before I release it. The next release should be this week end, still) |
Thank you for the merge :-) |
Released in the 1.18.8 version |
To support using graphql-maven-plugin instead of another code generator in an existing code base, the code generator is extended to support adding custom prefixes and suffixes on the generated java classes.
The need for this change was identified when trying to replace an old code generator in a very large code base.
The old generator is using a naming scheme with a suffix for input objects and types, where for example the type Droid would be named DroidGraphQLType (similarly for interfaces and enums). The code base have thousands of usages of these classes, making it risky to migrate all existing code, especially because there are existing classes (domain objects, and enums) used in the data fetchers, with the same class name as those that would be generated without a suffix.
The plugin is extended the following configuration options:
Tests have been added to verify the configuration and code generation. A fix has been made for
GraphqlUtilsTest
which failed on master.