graphql-java-codegen
graphql-java-codegen copied to clipboard
Introduce sub-packages for generated models
Is your feature request related to a problem? Please describe.
When the project is big and the GraphQL schema is huge the amount of generated classes inside one single package is enormous. For such projects, it's difficult to use IDE to find a specific class. I think it will be better if we will add an ability to separate generated files by groups (sub-packages), for example, inputs will to the package inputs
, enums to enums
, types to types
, etc. And as well can introduce supports defining sub-packages by using directive on top of the entity.
@kobylynskyi what do you think about this concept?
This is similar to a problem I mentioned earlier https://github.com/kobylynskyi/graphql-java-codegen/issues/289, mainly considering that package management will become extremely complex (Because this library uses a common import instead of a full class name like grpc. Maybe this is a place that needs to be improved in the future. Truth to tell, there are some problems with common import.).
Best practice: it may take the graphql specification to support package declaration to make the third-party library better implemented.
I like the idea, but my main concern is how to gracefully manage cross-package imports. Need to think about this a bit more, but in general, the feature request is ok to me.
@jxnu-liguobin, true! Looks like the topic from #289 brought up again 😄
Personally, I am not a fan of having types together with just the types. I would like to have items grouped by their use case. So, things related to each other should be in a package.
I noticed there is a proposal for namespace support (https://github.com/graphql/graphql-spec/issues/163) but it does not seem to be really active.
Yes, but at present, we can only store the schemas in different files according to requirements. Unless graphql/graphql-spec#163 proposal can be accepted by graphql-java.
So you would suggest something like a mapping from schema to package?
users.schema > com.kobylynskyi.graphql.users products.schema > com.kobylynskyi.graphql.products
@robbertnoordzij, you can already do that. Check https://github.com/kobylynskyi/graphql-java-codegen/tree/master/plugins/gradle#different-configurations-for-graphql-schemas
Closing due to inactivity