Comments (8)
We do have the option of specifying the generated package, but not per schema file - it's for all the generated files, so that doesn't address your use case.
Are you able to use extend type Query {}
for the queries in the second schema file? That should avoid defining the constants again.
from dgs-codegen.
So my use case is, i have stored 2 different schema files in a single directory. And hence I am getting the conflicts. Bascially, both the files are not related to each other. Hence both of them generate Query and Mutation constants in the same package and hence creates a conflict.
from dgs-codegen.
So do you want codegen to be run on both the files or just one of them?If just one, you can specify the schema path to point o the one file in the gradle config. If you want codegen on both, then you will need to update one of the schema files to have this for the query/mutation definition:
extend type Query {
yourQuery()
}
The other option is to have the schema files and related implementations in separate modules with separate build.gradle files that each define their own generateJavaTask.
Hope that helps.
from dgs-codegen.
Well i wanted to run the codegen on both the files. 1st opt I don't think is the right way to do it. 2nd option I have already implemented as a workaround.
However, just a suggestion why cannot we extend the platform to specify different packages for different files?
from dgs-codegen.
Could you elaborate on why extending the query type is not a good solution for your use case?
Extending the query/mutation type when we have multiple schema files in the same project is a common way to split your schema across different files in a project. This is how we use it internally as well.
While adding more configuration is definitely possible,it would make more sense if there isn't an existing solution for dealing with multiple schema files.
from dgs-codegen.
If you want to split generation for different schema files completely - for example when generating a Query API for an external service, the recommendation is put this schema file in a separate Gradle submodule, so that it can also have its own codegen configuration.
from dgs-codegen.
Not implementing a solution for this, since we already have recommendations for handling this use case.
from dgs-codegen.
The reason for not implementing this is that in most use-cases you would need to specify different codegen config altogether, not just package names, so typically it isn't the right setup.
from dgs-codegen.
Related Issues (20)
- generateJava fails with `Not a valid name: package` HOT 4
- Is the official document of generating codes outdated? or some classes are not auto-generated? HOT 1
- Generated Java-classes naming convention HOT 1
- Generating code from external schemas in JARs - META-INF requirement HOT 6
- Variable declaratino missing wenn miltiple operations are used
- Generate Deprecated Annotation For Queries HOT 1
- Fields with capital letters in the beginning are not deserialised by jackson. java
- Code is not compiling after aliases were added to projections HOT 3
- GraphQL interfaces should still be annotated when using the `@annotate` directive
- How to generate data class with "no arg constructor" and setter? (or a data class with builder) HOT 1
- Polymorphic Interfaces with default implementation HOT 3
- Support Custom Serialization for Date Fields in InputValueSerializer
- Error generating classes from generateClientApi or generateClientApiV2 HOT 9
- generating Java types failed with $ in graphql schema comment on interface
- Generating extended types that implement interfaces in the extension fails to generated the actual interface implementation HOT 1
- consider changing generateJava task name HOT 1
- gradle plugin not resolving dependencies properly HOT 1
- use instanceof in generated code
- use jakarta Generated HOT 7
- add appropriate nullity annotations HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dgs-codegen.