graphql.nadel.schema.UnderlyingSchemaGenerator.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of nadel Show documentation
Show all versions of nadel Show documentation
Nadel is a Java library that combines multiple GrahpQL services together into one API.
package graphql.nadel.schema
import graphql.schema.GraphQLSchema
import graphql.schema.idl.RuntimeWiring
import graphql.schema.idl.SchemaGenerator
import graphql.schema.idl.TypeDefinitionRegistry
import graphql.schema.idl.WiringFactory
import graphql.schema.idl.errors.SchemaProblem
internal class UnderlyingSchemaGenerator {
fun buildUnderlyingSchema(
serviceName: String,
underlyingTypeDefinitions: TypeDefinitionRegistry,
wiringFactory: WiringFactory,
): GraphQLSchema {
val schemaGenerator = SchemaGenerator()
val runtimeWiring = RuntimeWiring.newRuntimeWiring()
.wiringFactory(wiringFactory)
.build()
return try {
schemaGenerator.makeExecutableSchema(underlyingTypeDefinitions, runtimeWiring)
} catch (schemaProblem: SchemaProblem) {
throw ServiceSchemaProblem(
message = "There was a problem building the schema for '${serviceName}': ${schemaProblem.message}",
serviceName = serviceName,
cause = schemaProblem,
)
}
}
}