graphql.nadel.validation.NadelInterfaceValidation.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.validation.NadelSchemaValidationError.MissingConcreteTypes
import graphql.schema.GraphQLInterfaceType
internal class NadelInterfaceValidation {
fun validate(
schemaElement: NadelServiceSchemaElement,
): List {
return if (schemaElement.overall is GraphQLInterfaceType) {
validateHasImplementations(schemaElement)
} else {
emptyList()
}
}
private fun validateHasImplementations(
schemaElement: NadelServiceSchemaElement,
): List {
val underlyingSchema = schemaElement.service.underlyingSchema
val underlyingInterfaceType = schemaElement.underlying as GraphQLInterfaceType
val underlyingImplementations = underlyingSchema.getImplementations(underlyingInterfaceType)
return if (underlyingImplementations.isEmpty()) {
listOf(
MissingConcreteTypes(schemaElement)
)
} else {
emptyList()
}
}
}