com.coxautodev.graphql.tools.Utils.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of graphql-java-tools Show documentation
Show all versions of graphql-java-tools Show documentation
Tools to help map a GraphQL schema to existing Java objects.
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.TypeExtensionDefinition
/**
* @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 }
}