Skip to content
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

Compilation Errors in Generated Java Classes: Missing Methods, Duplicate Case Labels, and Method Definitions #67

Open
alexyzmarino opened this issue Jan 22, 2025 · 1 comment

Comments

@alexyzmarino
Copy link

alexyzmarino commented Jan 22, 2025

Issue Summary

I encountered multiple compilation errors when using the generated Java classes from the schema.json file for Admin API, which was fetched using the method described in Issue #65. These errors require manual intervention to resolve, making the process less efficient and prone to mistakes.

Steps to Reproduce

Fetch the schema.json file as described in Issue #65.
Use the graphql_java_gen Ruby code to generate Java classes from the schema.
Attempt to compile the generated Java code in a Maven project.

Compilation Errors

Here are some examples of the errors encountered during compilation:

Cannot find symbol:

[ERROR] /home/alex/projects/work/codecommit/3w-shopify-client/src/main/java/org/sample/shopify/admin/graphql/SaleEdge.java:[47,54] cannot find symbol
symbol:   method create(com.google.gson.JsonObject)
location: class it.trew.shopify.admin.graphql.UnknownSale

Duplicate case labels:

[ERROR] /home/alex/projects/work/codecommit/3w-shopify-client/src/main/java/org/sample/shopify/admin/graphql/UnknownHasMetafields.java:[135,13] duplicate case label
[ERROR] /home/alex/projects/work/codecommit/3w-shopify-client/src/main/java/org/sample/shopify/admin/graphql/UnknownHasMetafields.java:[143,13] duplicate case label

Method already defined:

[ERROR] /home/alex/projects/work/codecommit/3w-shopify-client/src/main/java/org/sample/shopify/admin/graphql/DisplayableErrorQuery.java:[966,34] method onProductVariantsBulkUpdateUserError(it.trew.shopify.admin.graphql.ProductVariantsBulkUpdateUserErrorQueryDefinition) is already defined in class it.trew.shopify.admin.graphql.DisplayableErrorQuery

Can the Ruby code responsible for generating these classes be updated to resolve these issues?

Specifically:

  • Ensure that all required methods are properly generated (e.g., create methods for unknown types).
  • Avoid generating duplicate case labels in the switch statements.
  • Prevent duplicate method definitions in the same class.

Additional Information

Ruby version: ruby 3.0.2p107
graphql_java_gen version: 0.2.1
Java version: openjdk version 1.8.0_402
Admin GraphQL API version: 2025-01

Let me know if any additional information is needed. Thank you for your help!

@louieyu
Copy link

louieyu commented Jan 23, 2025

Yes, may be you can delete the Duplicate Case Labels, and Method Definitions, and miss the method create,you can use the new.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants