Skip to content

Commit 28eb116

Browse files
authored
Merge pull request #757 from Netflix/fix/set-max-characters
Set the max character setting to Int.MAX.
2 parents cb9f828 + 6475cc6 commit 28eb116

File tree

1 file changed

+6
-2
lines changed
  • graphql-dgs-codegen-core/src/main/kotlin/com/netflix/graphql/dgs/codegen

1 file changed

+6
-2
lines changed

graphql-dgs-codegen-core/src/main/kotlin/com/netflix/graphql/dgs/codegen/CodeGen.kt

+6-2
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ class CodeGen(private val config: CodeGenConfig) {
6262

6363
companion object {
6464
private const val SDL_MAX_ALLOWED_SCHEMA_TOKENS: Int = Int.MAX_VALUE
65+
private const val SDL_MAX_CHARACTERS: Int = Int.MAX_VALUE
6566
private val logger: Logger = LoggerFactory.getLogger(CodeGen::class.java)
6667
}
6768

@@ -112,7 +113,10 @@ class CodeGen(private val config: CodeGenConfig) {
112113
*/
113114
private fun buildDocument(): Document {
114115
val options = ParserOptions.getDefaultParserOptions().transform { builder ->
115-
builder.maxTokens(SDL_MAX_ALLOWED_SCHEMA_TOKENS).maxWhitespaceTokens(SDL_MAX_ALLOWED_SCHEMA_TOKENS)
116+
builder
117+
.maxTokens(SDL_MAX_ALLOWED_SCHEMA_TOKENS)
118+
.maxWhitespaceTokens(SDL_MAX_ALLOWED_SCHEMA_TOKENS)
119+
.maxCharacters(SDL_MAX_CHARACTERS)
116120
}
117121
val parser = Parser()
118122

@@ -139,7 +143,7 @@ class CodeGen(private val config: CodeGenConfig) {
139143
parser.parseDocument(parserEnv)
140144
} catch (exception: InvalidSyntaxException) {
141145
// check if the schema is empty
142-
if (exception.sourcePreview == null || exception.sourcePreview.isBlank()) {
146+
if (exception.sourcePreview != null && exception.sourcePreview.isBlank()) {
143147
logger.warn("Schema is empty")
144148
// return an empty document
145149
return Document.newDocument().build()

0 commit comments

Comments
 (0)