graphql.nadel.validation.NadelSchemaValidation.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of nadel-engine-nextgen Show documentation
Show all versions of nadel-engine-nextgen Show documentation
Nadel is a Java library that combines multiple GrahpQL services together into one API.
The newest version!
package graphql.nadel.validation
import graphql.nadel.Service
import graphql.schema.GraphQLNamedSchemaElement
import graphql.schema.GraphQLSchema
class NadelSchemaValidation(
private val overallSchema: GraphQLSchema,
private val services: Map,
) {
fun validate(): Set {
val context = NadelValidationContext()
val typeValidation = NadelTypeValidation(context, overallSchema, services)
return services
.asSequence()
.flatMap { (_, service) ->
typeValidation.validate(service)
}
.toSet()
}
}
data class NadelServiceSchemaElement(
val service: Service,
val overall: GraphQLNamedSchemaElement,
val underlying: GraphQLNamedSchemaElement,
) {
internal fun toRef() = NadelServiceSchemaElementRef(service, overall, underlying)
}
/**
* This is used to create a version of [NadelServiceSchemaElement] that has a proper
* [hashCode] definition instead of relying on identity hashCodes.
*/
internal data class NadelServiceSchemaElementRef(
val service: String,
val overall: String,
val underlying: String,
) {
companion object {
operator fun invoke(
service: Service,
overall: GraphQLNamedSchemaElement,
underlying: GraphQLNamedSchemaElement,
) = NadelServiceSchemaElementRef(service.name, overall.name, underlying.name)
}
}