Skip to content

Commit

Permalink
Merge pull request #722 from graphql-java-kickstart/bugfix/716
Browse files Browse the repository at this point in the history
Allow parsing large schema files
  • Loading branch information
oryan-block authored Nov 18, 2022
2 parents a319992 + edde512 commit bf41edb
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/main/kotlin/graphql/kickstart/tools/SchemaParserBuilder.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package graphql.kickstart.tools

import graphql.language.Definition
import graphql.language.Document
import graphql.parser.MultiSourceReader
import graphql.parser.Parser
import graphql.parser.ParserOptions
import graphql.schema.GraphQLScalarType
Expand Down Expand Up @@ -168,12 +169,16 @@ class SchemaParserBuilder {
val parser = Parser()
val documents = mutableListOf<Document>()
try {
files.forEach { documents.add(parser.parseDocument(readFile(it), it)) }
val options = ParserOptions
.getDefaultParserOptions()
.transform { o -> o.maxTokens(MAX_VALUE) }

files.forEach {
val sourceReader = MultiSourceReader.newMultiSourceReader().string(readFile(it), it).trackData(true).build()
documents.add(parser.parseDocument(sourceReader, options))
}

if (schemaString.isNotEmpty()) {
val options = ParserOptions
.getDefaultParserOptions()
.transform { o -> o.maxTokens(MAX_VALUE) }
documents.add(parser.parseDocument(schemaString.toString(), options))
}
} catch (pce: ParseCancellationException) {
Expand Down

0 comments on commit bf41edb

Please sign in to comment.