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

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy