jvmMain.configuration.GraphRaptorComponent.kt Maven / Gradle / Ivy
The newest version!
package io.fluidsonic.raptor
import io.fluidsonic.raptor.graphql.internal.*
public class GraphRaptorComponent internal constructor() :
RaptorComponent.Base(RaptorGraphqlPlugin),
RaptorTaggableComponent {
private val definitions: MutableList = mutableListOf()
private var includesDefaultDefinitions = false
@RaptorDsl
public fun definitions(vararg definitions: RaptorGraphDefinition) {
definitions(definitions.asIterable())
}
@RaptorDsl
public fun definitions(definitions: Iterable) {
this.definitions += definitions
}
@RaptorDsl
public fun includeDefaultDefinitions() {
if (includesDefaultDefinitions)
return
includesDefaultDefinitions = true
definitions(RaptorGraphDefaults.definitions)
}
internal fun toGraphRoute() =
GraphRoute(
system = GraphSystemDefinitionBuilder.build(definitions)
.let(GraphTypeSystemBuilder::build)
.let(GraphSystemBuilder::build)
)
internal companion object {
val key = RaptorComponentKey("graphql")
}
}