Skip to content

Commit 4a69e6b

Browse files
committed
Adding Mojo configuration to set the token limit
1 parent b13e059 commit 4a69e6b

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

docs/codegen-options.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
| `supportUnknownFields` | Boolean | False | Specifies whether api classes should support unknown fields during serialization or deserialization. If `true`, classes will include a property of type [`java.util.Map<String,Object>`](https://docs.oracle.com/javase/8/docs/api/index.html?java/util/Map.html) that will store unknown fields. |
6969
| `unknownFieldsPropertyName` | String | userDefinedFields | Specifies the name of the property to be included in api classes to support unknown fields during serialization or deserialization |
7070
| `skip` | Boolean | False | If true, then code generation will not happen |
71+
| `tokenLimit` | Integer | 15000 | Specifies the maximum number of GraphQL grammar tokens to process.
7172

7273

7374
### Option `graphqlSchemas`

plugins/maven/graphql-java-codegen-maven-plugin/src/main/java/io/github/kobylynskyi/graphql/codegen/GraphQLCodegenMojo.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import com.kobylynskyi.graphql.codegen.supplier.MappingConfigSupplier;
1717
import com.kobylynskyi.graphql.codegen.supplier.MergeableMappingConfigSupplier;
1818
import com.kobylynskyi.graphql.codegen.supplier.SchemaFinder;
19+
import graphql.parser.ParserOptions;
1920
import org.apache.maven.model.Resource;
2021
import org.apache.maven.plugin.AbstractMojo;
2122
import org.apache.maven.plugin.MojoExecutionException;
@@ -248,6 +249,12 @@ public class GraphQLCodegenMojo extends AbstractMojo implements GraphQLCodegenCo
248249
@Parameter(defaultValue = "false")
249250
private boolean skip;
250251

252+
/**
253+
* Maximum number of GraphQL grammar tokens to process.
254+
*/
255+
@Parameter(defaultValue = "15000")
256+
private int tokenLimit;
257+
251258
@Override
252259
public void execute() throws MojoExecutionException {
253260
addCompileSourceRootIfConfigured();
@@ -338,6 +345,9 @@ private GraphQLCodegen instantiateCodegen(MappingConfig mappingConfig) throws IO
338345
GeneratedLanguage language = mappingConfigSupplier.map(Supplier::get)
339346
.map(MappingConfig::getGeneratedLanguage)
340347
.orElse(generatedLanguage);
348+
349+
ParserOptions.setDefaultParserOptions(ParserOptions.newParserOptions().maxTokens(tokenLimit).build());
350+
341351
switch (language) {
342352
case JAVA:
343353
return new JavaGraphQLCodegen(getSchemas(), graphqlQueryIntrospectionResultPath,

0 commit comments

Comments
 (0)