graphql-java-generator / graphql-gradle-plugin-project

graphql-gradle-plugin is a Gradle Plugin for GraphQL, based on graphql-java. It accelerates the development for both the client and the server, by generating the Java code. It allows a quicker development when in contract-first approach, by avoiding to code the boilerplate code.
https://graphql-maven-plugin-project.graphql-java-generator.com/
MIT License
54 stars 8 forks source link

Max tokens property is not recognized during client codegen #11

Closed mitcharene closed 2 years ago

mitcharene commented 2 years ago

Despite setting maxTokens to a very high number in generateClientCodeConf, my build still fails due to the 15000 token limit

IDE = IntelliJ graphQLPluginVersion = 1.18.6

Screen Shot 2022-06-09 at 4 42 50 PM
etienne-sf commented 2 years ago

Hello,

I had issues when trying to test this parameter: I was unable to set automatic tests on this subject.

I'll check all this again.

Or set a default max value to maxInt, as obviously, there would be not attack in the plugin's use case.

Étienne

etienne-sf commented 2 years ago

I did several tests with the maxTokens parameter, including one with the same configuration as yours.

I could check the maxTokens parameter is properly managed.

My test was to put this parameter to 1. And I got the error saying that there are than 1 token.

But...

When I removed the maxTokens, gradle still remembered the 1 value. Which is very strange. And killing the daemon would correct the issue.

Can you check after killing the gradle daemon ? (after a reboot, for instance, to be sure)

Étienne

etienne-sf commented 2 years ago

I have another question: what is your gradle version?

etienne-sf commented 2 years ago

And can you provide the schema that generates this error?

mitcharene commented 2 years ago

Thanks @etienne-sf for looking at this. To answer your questions:

gradleVersion = 7.4.2

Can you check after killing the gradle daemon ? (after a reboot, for instance, to be sure)

I've tried this (with gradle --stop and running gradle --no-daemon clean build just make sure no old config setting gets reused), but I'm still facing the issue. I was able to build once and it did seem related to gradle not picking up my updated config but I am unable to repro a successful build.

And can you provide the schema that generates this error?

Unfortunately I cannot. It is proprietary

Or set a default max value to maxInt, as obviously, there would be not attack in the plugin's use case.

I think this is a reasonable approach to unblock me while we work to figure out the issue with the config. As a comparison, Netflix's DGS CodeGen uses maxInt

Let me know how I can further assist

MrLamberg commented 2 years ago

Hi. I meet this problem on GitHub graphql scheme. https://docs.github.com/public/schema.docs.graphql

I tried all advice on the topic, and it didn't help. Maybe I can build a config object in gradle.build manually?

etienne-sf commented 2 years ago

The limit of 15000 is not in the plugin's code, but in the graphql-java dependency.

As in all my tests, the value provided in the gradle conf is propagated into this dependency, I think there is an issue somewhere else.

I'll deliver a release, with the maxTokens default value set to the maximum integer value. As the schema parsing is done at compile time, the protection in graphql-java doesn't seem to be useful.

This should solve this issue.

Étienne

etienne-sf commented 2 years ago

The correction is available in the new release (1.18.7)