GraphQLCodegenKeys.scala 5.5 KB
Newer Older
梦境迷离's avatar
梦境迷离 已提交
1 2 3 4 5 6
package io.github.dreamylost.graphql.codegen

import java.util

import com.kobylynskyi.graphql.codegen.model.{ ApiNamePrefixStrategy, ApiRootInterfaceStrategy }
import sbt._
7
import com.kobylynskyi.graphql.codegen.model.ApiInterfaceStrategy
梦境迷离's avatar
梦境迷离 已提交
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45

/**
 *
 * @author liguobin@growingio.com
 * @version 1.0,2020/7/15
 */
trait GraphQLCodegenKeys {

  //Conflict with SBT key
  val generatePackageName = settingKey[Option[String]]("generatePackageName")

  //Scala collection and asJava cannot be used. The latter one uses the put method, which is not supported by Scala collection
  val customTypesMapping = settingKey[util.Map[String, String]]("customTypesMapping")

  val apiNamePrefix = settingKey[Option[String]]("apiNamePrefix")

  val apiNameSuffix = settingKey[String]("apiNameSuffix")

  val apiRootInterfaceStrategy = settingKey[ApiRootInterfaceStrategy]("apiRootInterfaceStrategy")

  val apiNamePrefixStrategy = settingKey[ApiNamePrefixStrategy]("apiNamePrefixStrategy")

  val modelNamePrefix = settingKey[Option[String]]("Prefix to append to the model class names.")

  val modelNameSuffix = settingKey[Option[String]]("Suffix to append to the model class names.")

  val apiPackageName = settingKey[Option[String]]("Java package to use when generating the API classes.")

  val modelPackageName = settingKey[Option[String]]("Java package to use when generating the model classes.")

  val generateBuilder = settingKey[Boolean]("Specifies whether generated model classes should have builder.")

  val generateApis = settingKey[Boolean]("Specifies whether api classes should be generated as well as model classes.")

  val typeResolverPrefix = settingKey[Option[String]]("typeResolverPrefix")

  val typeResolverSuffix = settingKey[String]("typeResolverSuffix")

46
  val customAnnotationsMapping = settingKey[util.Map[String, util.List[String]]]("customAnnotationsMapping")
梦境迷离's avatar
梦境迷离 已提交
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96

  val generateEqualsAndHashCode = settingKey[Boolean]("Specifies whether generated model classes should have equals and hashCode methods defined.")

  val generateImmutableModels = settingKey[Boolean]("generateImmutableModels")

  val generateToString = settingKey[Boolean]("Specifies whether generated model classes should have toString method defined.")

  val subscriptionReturnType = settingKey[Option[String]]("subscriptionReturnType")

  val modelValidationAnnotation = settingKey[String]("Annotation for mandatory (NonNull) fields. Can be None/empty.")

  val generateParameterizedFieldsResolvers = settingKey[Boolean]("If true, then generate separate Resolver interface for parametrized fields. If false, then add field to the type definition and ignore field parameters.")

  val generateExtensionFieldsResolvers = settingKey[Boolean]("Specifies whether all fields in extensions (extend type and extend interface) should be present in Resolver interface instead of the type class itself.")

  val generateDataFetchingEnvironmentArgumentInApis = settingKey[Boolean]("If true, then graphql.schema.DataFetchingEnvironment env will be added as a last argument to all methods of root type resolvers and field resolvers.")

  val generateModelsForRootTypes = settingKey[Boolean]("generateModelsForRootTypes")

  val fieldsWithResolvers = settingKey[util.Set[String]]("fieldsWithResolvers")

  val fieldsWithoutResolvers = settingKey[util.Set[String]]("fieldsWithoutResolvers")

  val generateClient = settingKey[Boolean]("generateClient")

  val requestSuffix = settingKey[String]("Specifies whether client-side classes should be generated for each query, mutation and subscription. This includes: Request class (contains input data) and ResponseProjection class (contains response fields).")

  val responseSuffix = settingKey[String]("responseSuffix")

  val responseProjectionSuffix = settingKey[String]("Specifies whether client-side classes should be generated for each query, mutation and subscription. This includes: Request class (contains input data) and ResponseProjection class (contains response fields).")

  val parametrizedInputSuffix = settingKey[String]("parametrizedInputSuffix")

  val jsonConfigurationFile = settingKey[Option[String]]("jsonConfigurationFile")

  val parentInterfaces = settingKey[ParentInterfacesConfig]("parentInterfaces")

  val graphqlSchemas = settingKey[SchemaFinderConfig]("graphqlSchemas")

  val outputDir = settingKey[File]("outputDir")

  val graphqlSchemaPaths = settingKey[Seq[String]]("Locations of GraphQL schemas.")

  //use different paths
  val graphqlSchemaValidate = inputKey[Seq[String]]("graphqlSchemaValidatePaths")

  val graphqlCodegen = taskKey[Seq[File]]("Generate Java code")

  val graphqlCodegenValidate = taskKey[Unit]("Validate graphql schema")

97
  val apiReturnType = settingKey[Option[String]]("apiReturnType")
梦境迷离's avatar
梦境迷离 已提交
98

99
  val apiReturnListType = settingKey[Option[String]]("apiReturnListType")
梦境迷离's avatar
梦境迷离 已提交
100

101 102 103 104 105
  val directiveAnnotationsMapping = settingKey[util.Map[String, util.List[String]]]("directiveAnnotationsMapping")

  val apiInterfaceStrategy = settingKey[ApiInterfaceStrategy]("apiInterfaceStrategy")

  val useOptionalForNullableReturnTypes = settingKey[Boolean]("useOptionalForNullableReturnTypes")
梦境迷离's avatar
梦境迷离 已提交
106

107 108
  val graphqlQueryIntrospectionResultPath = settingKey[Option[String]]("graphqlQueryIntrospectionResultPath")

梦境迷离's avatar
梦境迷离 已提交
109 110 111 112
  //for version
  val javaxValidationApiVersion = settingKey[Option[String]]("javax-validation-api version")
  val graphqlJavaCodegenVersion = settingKey[Option[String]]("graphql java codegen version")

113 114
  val generateCodegenTargetPath = settingKey[File]("The path for graphqlCodegen to save java code which generate by plugin")

梦境迷离's avatar
梦境迷离 已提交
115
}