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

graphql.nadel.validation.util.NadelSchemaUtil.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-12-10T04-34-06-f2ee9344
Show newest version
package graphql.nadel.validation.util

import graphql.language.OperationDefinition
import graphql.nadel.Service
import graphql.nadel.definition.renamed.getRenamedOrNull
import graphql.schema.GraphQLNamedType

internal object NadelSchemaUtil {
    fun getUnderlyingType(overallType: GraphQLNamedType, service: Service): GraphQLNamedType? {
        return service.underlyingSchema.getType(getUnderlyingName(overallType)) as GraphQLNamedType?
    }

    fun getUnderlyingName(type: GraphQLNamedType): String {
        return type.getRenamedOrNull()?.from ?: type.name
    }

    fun isOperation(type: GraphQLNamedType): Boolean {
        return type.name.equals(OperationDefinition.Operation.QUERY.toString(), ignoreCase = true)
            || type.name.equals(OperationDefinition.Operation.MUTATION.toString(), ignoreCase = true)
            || type.name.equals(OperationDefinition.Operation.SUBSCRIPTION.toString(), ignoreCase = true)
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy