io.github.darvld.wireframe.base.WireframeBasePlugin.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of compiler-core Show documentation
Show all versions of compiler-core Show documentation
A GraphQL server library for Kotlin.
package io.github.darvld.wireframe.base
import com.squareup.kotlinpoet.STRING
import com.squareup.kotlinpoet.TypeAliasSpec
import graphql.schema.GraphQLEnumType
import graphql.schema.GraphQLInputObjectType
import graphql.schema.GraphQLNamedType
import graphql.schema.GraphQLObjectType
import io.github.darvld.wireframe.ProcessingEnvironment
import io.github.darvld.wireframe.WireframeCompilerPlugin
import io.github.darvld.wireframe.extensions.idTypeAlias
import io.github.darvld.wireframe.extensions.isRouteType
public class WireframeBasePlugin : WireframeCompilerPlugin {
override fun processType(type: GraphQLNamedType, environment: ProcessingEnvironment) {
if (type.isRouteType()) return
if (type is GraphQLEnumType) {
processEnumType(type, environment)
return
}
if (type is GraphQLInputObjectType) {
processInputType(type, environment)
return
}
if (type is GraphQLObjectType) {
processOutputType(type, environment)
}
}
override fun beforeProcessing(environment: ProcessingEnvironment) {
val typeName = environment.idTypeAlias()
val spec = TypeAliasSpec.builder(typeName.simpleName, STRING).build()
environment.output(typeName.packageName, typeName.simpleName) { addTypeAlias(spec) }
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy