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

graphql.nadel.validation.NadelInterfaceValidation.kt Maven / Gradle / Ivy

Go to download

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()
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy