All Downloads are FREE. Search and download functionalities are using the official Maven repository.

graphql.nadel.schema.UnderlyingSchemaGenerator.kt Maven / Gradle / Ivy

Go to download

Nadel is a Java library that combines multiple GrahpQL services together into one API.

There is a newer version: 2024-11-20T03-31-21-302962b7
Show newest version
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,
            )
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy