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

com.coxautodev.graphql.tools.Utils.kt Maven / Gradle / Ivy

The newest version!
package com.coxautodev.graphql.tools

import graphql.language.FieldDefinition
import graphql.language.ListType
import graphql.language.NonNullType
import graphql.language.ObjectTypeDefinition
import graphql.language.Type
import graphql.language.ObjectTypeExtensionDefinition

/**
 * @author Andrew Potter
 */

internal typealias GraphQLRootResolver = GraphQLResolver
internal typealias JavaType = java.lang.reflect.Type
internal typealias GraphQLLangType = graphql.language.Type<*>

internal fun Type<*>.unwrap(): Type<*> = when(this) {
    is NonNullType -> this.type.unwrap()
    is ListType -> this.type.unwrap()
    else -> this
}

internal fun ObjectTypeDefinition.getExtendedFieldDefinitions(extensions: List): List {
    return this.fieldDefinitions + extensions.filter { it.name == this.name }.flatMap { it.fieldDefinitions }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy