Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,6 @@
<artifactId>graphql-java</artifactId>
<version>${graphql-java.version}</version>
</dependency>
<dependency>
<groupId>org.antlr</groupId>
<artifactId>antlr4-runtime</artifactId>
<version>4.11.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson</groupId>
<artifactId>jackson-bom</artifactId>
Expand Down Expand Up @@ -162,10 +156,6 @@
<groupId>com.graphql-java</groupId>
<artifactId>graphql-java</artifactId>
</dependency>
<dependency>
<groupId>org.antlr</groupId>
<artifactId>antlr4-runtime</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml</groupId>
<artifactId>classmate</artifactId>
Expand Down
31 changes: 6 additions & 25 deletions src/main/kotlin/graphql/kickstart/tools/SchemaParserBuilder.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ import graphql.parser.ParserOptions
import graphql.schema.GraphQLScalarType
import graphql.schema.idl.RuntimeWiring
import graphql.schema.idl.SchemaDirectiveWiring
import org.antlr.v4.runtime.RecognitionException
import org.antlr.v4.runtime.misc.ParseCancellationException
import java.text.NumberFormat
import kotlin.Int.Companion.MAX_VALUE
import kotlin.reflect.KClass
Expand Down Expand Up @@ -178,22 +176,13 @@ class SchemaParserBuilder {
}

private fun parseDocuments(): List<Document> {
try {
val documents = files.map { parseDocument(listOf(Source(readFile(it), it))) }.toMutableList()

if (schemaStrings.any { it.text.isNotBlank() }) {
documents.add(parseDocument(schemaStrings))
}

return documents
} catch (pce: ParseCancellationException) {
val cause = pce.cause
if (cause != null && cause is RecognitionException) {
throw InvalidSchemaError(pce, cause)
} else {
throw pce
}
val documents = files.map { parseDocument(listOf(Source(readFile(it), it))) }.toMutableList()

if (schemaStrings.any { it.text.isNotBlank() }) {
documents.add(parseDocument(schemaStrings))
}

return documents
}

private fun parseDocument(sources: List<Source>): Document {
Expand Down Expand Up @@ -243,13 +232,5 @@ class SchemaParserBuilder {
}
}

class InvalidSchemaError(
pce: ParseCancellationException,
private val recognitionException: RecognitionException
) : RuntimeException(pce) {
override val message: String
get() = "Invalid schema provided (${recognitionException.javaClass.name}) at: ${recognitionException.offendingToken}"
}

internal class SchemaSyntaxException(message: String, location: SourceLocation, e: InvalidSyntaxException) :
InvalidSyntaxException(message, location, e.offendingToken, e.sourcePreview, e)
1 change: 0 additions & 1 deletion src/main/kotlin/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
requires com.fasterxml.jackson.datatype.jdk8;
requires com.fasterxml.classmate;

requires org.antlr.antlr4.runtime;
requires org.apache.commons.lang3;
requires org.reactivestreams;
requires org.slf4j;
Expand Down
Loading