Open davidvc opened 3 months ago
Sorry, forgot to mention, I am using version 1.50 of your plugin. Thanks.
<plugin>
<groupId>io.github.deweyjose</groupId>
<artifactId>graphqlcodegen-maven-plugin</artifactId>
<version>1.50</version>
Hi @davidvc - I will take a look tonight and follow up.
Great thanks!
On Tue, Jul 30, 2024 at 12:52 PM deweyjose @.***> wrote:
Hi @davidvc https://github.com/davidvc - I will take a look tonight and follow up.
— Reply to this email directly, view it on GitHub https://github.com/deweyjose/graphqlcodegen/issues/167#issuecomment-2259098114, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAARO73IJQZWK5BX3QFPBUDZO7VJVAVCNFSM6AAAAABLSKAHVKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENJZGA4TQMJRGQ . You are receiving this because you were mentioned.Message ID: @.***>
I've created a PR example repo run some experiments.
With the following configuration
<configuration>
<packageName>com.acme</packageName>
<generateClientApiV2>true</generateClientApiV2>
<includeMutations>
<param>addPage</param>
</includeMutations>
<includeQueries></includeQueries>
<includeSubscriptions></includeSubscriptions>
<skipEntityQueries>true</skipEntityQueries>
<maxProjectionDepth>2</maxProjectionDepth>
<generateDataTypes>false</generateDataTypes>
<schemaPaths>
<param>src/main/resources/schema/schema.graphqls</param>
</schemaPaths>
</configuration>
I see the following output (similar to yours):
--output-dir=/Users/dewey/repos/graphqlcodegen-example/client/target/generated-sources
--package-name=com.acme
--sub-package-name-client=client
--sub-package-name-datafetchers=datafetchers
--sub-package-name-types=types
--sub-package-name-docs=docs
--write-to-disk
--language=JAVA
--skip-generate-data-types
--include-mutation=addPage
--skip-entities
And I see the following generated client code:
By types
did you mean query, projection root etc in the client package?
I think what's probably happening is the <includeQueries>
configuration is not behaving as expected. Leaving it emptyt like that is essentially telling the plugin to generate all queries, which will pull in all the types associated with them.
By adding the following to my configuration:
<includeMutations>
<param>addBook</param>
</includeMutations>
<includeQueries>
<param>""</param>
</includeQueries>
The generated code is much smaller for me now. I also updated the mutation to accept an input type to verify types only has the type required by the single mutation.
schema:
type Query {
books: [Book]
publishers: [Publisher]
authors: [Author]
}
type Mutation {
addPage(bookId: ID!, number: Int!, content: String!): Page
addPublisher(name: String!): Publisher
addAuthor(name: String!): Author
addBook(book: BookInput!): Book
}
input BookInput {
title: String!
}
type Book {
id: ID!
title: String!
pages: [Page]
}
type Page {
id: ID!
number: Int!
content: String!
}
type Publisher {
id: ID!
name: String!
books: [Book]
}
type Author {
id: ID!
name: String!
books: [Book]
}
@davidvc Could you try adding <param>""</param>
to each of the include lists you want to disable. This is more inline with the gradle example you referenced above.
The client code generation that uses the config object constructed by input params (both this maven plugin and the DGS gradle plugin) needs something in the array to filter against. If the array is empty there is no filter.
This is great, thanks! I'll give that a try when I get back in the office on Monday.
David
On Sat, Aug 3, 2024, 8:30 AM deweyjose @.***> wrote:
@davidvc https://github.com/davidvc For now I'd try adding - to each of the include lists you want to disable for now. I'll take a look at making this more convenient (or updating the docs) in a new point release.
— Reply to this email directly, view it on GitHub https://github.com/deweyjose/graphqlcodegen/issues/167#issuecomment-2266812986, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAARO7Y2MCVUBLCDZSKJLODZPTZQZAVCNFSM6AAAAABLSKAHVKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENRWHAYTEOJYGY . You are receiving this because you were mentioned.Message ID: @.***>
Hi @davidvc just following up to see if you're all set. Would like to close this issue if so.
Hey I'm sorry. I got pulled into other things. Let me make sure this works I'll get back to you soon.
On Fri, Aug 16, 2024, 7:46 AM deweyjose @.***> wrote:
Hi @davidvc https://github.com/davidvc just following up to see if you're all set. Would like to close this issue if so.
— Reply to this email directly, view it on GitHub https://github.com/deweyjose/graphqlcodegen/issues/167#issuecomment-2293646735, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAARO74PHWXEOISNYOULYMDZRYGDZAVCNFSM6AAAAABLSKAHVKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEOJTGY2DMNZTGU . You are receiving this because you were mentioned.Message ID: @.***>
Yep, that worked! I also got a much smaller set! Thanks so much!
Do you want to keep this open, since this is just a workaround?
Or is the bug in the core codegen repo?
I'm inclined to just close and highlight the subtleties in the README.
IMO <param>""</param>
is aligned with how the gradle plugin managed by Netflix behaves and is documented.
OK sounds good. Thanks again! A big win for us, we have a massive schema
On Mon, Aug 19, 2024 at 7:36 AM deweyjose @.***> wrote:
I'm inclined to just close and highlight the subtleties in the README.
IMO "" is aligned with how the gradle plugin managed by Netflix behaves and is documented https://netflix.github.io/dgs/generating-code-from-schema/#generating-query-apis-for-external-services . image.png (view on web) https://github.com/user-attachments/assets/0aa1a724-84f6-4c05-bd2c-0dde317ae1d5
— Reply to this email directly, view it on GitHub https://github.com/deweyjose/graphqlcodegen/issues/167#issuecomment-2296736960, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAARO73I4H754P4LK5L3K7TZSH7HLAVCNFSM6AAAAABLSKAHVKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEOJWG4ZTMOJWGA . You are receiving this because you were mentioned.Message ID: @.***>
I'm not sure what happened. Perhaps I didn't test with full schema like I thought I did. With this configuration I got the following output, and 2,880 types were generated from a 78,000 line supergraph :(
<configuration>
<schemaPaths>
<param>src/main/resources/schema/supergraph.graphqls</param>
</schemaPaths>
<packageName>com.ebay.app.generated.schema</packageName>
<typeMapping>
<Long>java.lang.Long</Long>
<Decimal>java.math.BigDecimal</Decimal>
<CountryCode>java.lang.String</CountryCode>
<CurrencyCode>com.ebay.cos.type.v3.base.CurrencyCodeEnum</CurrencyCode>
<Time>java.time.OffsetTime</Time>
<Date>java.time.OffsetDateTime</Date>
</typeMapping>
<generateClientApiV2>true</generateClientApiV2>
<skipEntityQueries>true</skipEntityQueries>
<includeMutations>
<param>createListingDraft</param>
</includeMutations>
<includeQueries>
<param>""</param>
</includeQueries>
</configuration>
</plugin>
Here's the debug output
[INFO] Codegen config:
--output-dir=/Users/dvancouvering/projects/dvancouvering/lps/lpsService/target/generated-sources
--package-name=com.ebay.app.generated.schema
--sub-package-name-client=client
--sub-package-name-datafetchers=datafetchers
--sub-package-name-types=types
--sub-package-name-docs=docs
--write-to-disk
--language=JAVA
--generate-data-types
--include-query=""
--include-mutation=createListingDraft
--skip-entities
I just saw generate-data-type was true. I changed it to false, same result, all types generated. I'm sure I'm missing something obvious :(
[INFO] Codegen config:
--output-dir=/Users/dvancouvering/projects/dvancouvering/lps/lpsService/target/generated-sources
--package-name=com.ebay.app.generated.schema
--sub-package-name-client=client
--sub-package-name-datafetchers=datafetchers
--sub-package-name-types=types
--sub-package-name-docs=docs
--write-to-disk
--language=JAVA
--skip-generate-data-types
--include-query=""
--include-mutation=createListingDraft
--skip-entities
--type-mapping CountryCode=java.lang.String
--type-mapping CurrencyCode=com.ebay.cos.type.v3.base.CurrencyCodeEnum
--type-mapping Date=java.time.OffsetDateTime
--type-mapping Decimal=java.math.BigDecimal
--type-mapping Long=java.lang.Long
--type-mapping Time=java.time.OffsetTime
No worries, @davidvc - any chance you can test with a newer version of the plugin?
I'll try again tonight to make sure I wasn't missing something in my config as well.
Hello. I am trying to follow the instructions documented here to limit the types generated. We have a very large federated supergraph (sorry I am not able to share it publicly), and I just want the code necessary for a specific mutation.
Here is what the pom configuration looks like for the plugin:
I run
mvn clean generate-sources
and it generates code for every single type, input type, query, mutation and enum in the entire schema.Here is the output provided by your plugin for the call made to the core codegen library:
This all looks correct according to the documentation. So I'm not sure what I'm doing wrong here. It makes the codegen essentialy unusable because such a massive amount of code is being generated. There should be about 25 types generated, instead I get around 500.
Thanks!