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 of generated classes fails if GraphQL Types have a lot of fields #1017

Closed
andreloeffelmann opened this issue Nov 28, 2022 · 3 comments
Assignees
Labels
bug Something isn't working good-first-issue Good for newcomers
Milestone

Comments

@andreloeffelmann
Copy link
Contributor

Issue Description

I have to deal with a GraphQL API having a Type which has 377(!) fields.
When I generate the client classes out of the schema, the generated java class has two constructors: the default empty constructor and a constructor with all 377 fields as arguments.
This leads to a compilation error "too many parameters" since a constructor with that much parameters violates the java language specification.

Steps to Reproduce

  • Define a schema with a type having a lot of fields.
  • Generate and compile the client java classes

Expected Result

  • The compilation should work. In that case, a no-args constructor should be generated only.
  • Maybe we could have a config flag generateNoArgsConstrutctorOnly which defaults to false. If set to true, only the default no-args constructor will be generated, but not the one having all fields as parameter arguments.
@andreloeffelmann andreloeffelmann added the bug Something isn't working label Nov 28, 2022
@kobylynskyi kobylynskyi added help-wanted Extra attention is needed good-first-issue Good for newcomers labels Feb 19, 2023
@kobylynskyi kobylynskyi self-assigned this Feb 24, 2023
@kobylynskyi kobylynskyi removed the help-wanted Extra attention is needed label Feb 24, 2023
@kobylynskyi kobylynskyi added this to the 5.6.0 milestone Feb 24, 2023
@kobylynskyi
Copy link
Owner

This is a good one.
I will add a new config as you suggested.

Just a little more info on this topic from JVM spec:

The number of method parameters is limited to 255 by the definition of a method descriptor (§4.3.3), where the limit includes one unit for this in the case of instance or interface method invocations. Note that a method descriptor is defined in terms of a notion of method parameter length in which a parameter of type long or double contributes two units to the length, so parameters of these types further reduce the limit.

@kobylynskyi
Copy link
Owner

Added a new config option: generateNoArgsConstructorOnly.
Will include this in the upcoming release. Stay tuned.

@andreloeffelmann
Copy link
Contributor Author

Thanks, great :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good-first-issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants