Skip to content

Latest commit

 

History

History
34 lines (28 loc) · 1.01 KB

code-generation-with-spring-boot-integration.md

File metadata and controls

34 lines (28 loc) · 1.01 KB

Code generation with Spring Boot integration

This code generation can be configured to generate code which can simplify usage with the Spring Boot integration from this toolkit.

Usage

To enable it add the following property to the Gradle Plugin configuration:

graphqlKotlinCodegen {
    // ...
    enableSpringBootIntegration.set(true)
    // ...
}

Effects on the generated code

The code generator will add the GQLResolver annotation to the generated resolvers.

To be more precise take a look at the following example:

@GQLResolver(CONTAINER, FIELD) // <- This annotation will be added.
abstract class GQLQueryGetUser : DataFetcher<Any> {
  abstract fun resolve(env: GQLEnv<Any>): Any

  override fun get(env: DataFetchingEnvironment): Any {
    val map = env.arguments
    return resolve(env = GQLEnv<Any>(env))
  }

  companion object Meta {
    const val CONTAINER: String = "Query"

    const val FIELD: String = "getUser"
  }
}