From 5fde09900da0968492cc9f3b9c2722e2f6028349 Mon Sep 17 00:00:00 2001
From: Bogdan Kobylynskyi <92bogdan@gmail.com>
Date: Sun, 11 Sep 2022 10:29:37 -0400
Subject: [PATCH 01/25] Update to next development version: 5.5.1-SNAPSHOT
---
build.gradle | 2 +-
plugins/gradle/example-client-kotlin/build.gradle | 6 +++---
plugins/gradle/example-client/build.gradle | 4 ++--
plugins/gradle/example-server/build.gradle | 2 +-
.../gradle/graphql-java-codegen-gradle-plugin/build.gradle | 2 +-
plugins/maven/example-client/pom.xml | 2 +-
plugins/maven/example-server/pom.xml | 2 +-
plugins/maven/graphql-java-codegen-maven-plugin/pom.xml | 4 ++--
.../example-client-scala/project/plugins.sbt | 2 +-
.../example-client-scala/version.sbt | 2 +-
.../example-client/project/plugins.sbt | 2 +-
.../graphql-codegen-sbt-plugin/example-client/version.sbt | 2 +-
.../graphql-codegen-sbt-plugin/simple/project/plugins.sbt | 2 +-
.../sbt-test/graphql-codegen-sbt-plugin/simple/version.sbt | 2 +-
plugins/sbt/graphql-java-codegen-sbt-plugin/version.sbt | 2 +-
15 files changed, 19 insertions(+), 19 deletions(-)
diff --git a/build.gradle b/build.gradle
index c8105c553..7b6595024 100644
--- a/build.gradle
+++ b/build.gradle
@@ -9,7 +9,7 @@ plugins {
id "org.sonarqube" version "3.2.0"
}
-def graphqlCodegenVersion = '5.5.0' // This variable used in the automatic release process
+def graphqlCodegenVersion = '5.5.1-SNAPSHOT' // This variable used in the automatic release process
group = "io.github.kobylynskyi"
version = graphqlCodegenVersion
diff --git a/plugins/gradle/example-client-kotlin/build.gradle b/plugins/gradle/example-client-kotlin/build.gradle
index 193db58cf..12998fb7a 100644
--- a/plugins/gradle/example-client-kotlin/build.gradle
+++ b/plugins/gradle/example-client-kotlin/build.gradle
@@ -4,10 +4,10 @@ import io.github.kobylynskyi.graphql.codegen.gradle.GraphQLCodegenGradleTask
plugins {
id "java"
id "org.jetbrains.kotlin.jvm" version "1.6.21"
- id "io.github.kobylynskyi.graphql.codegen" version "5.5.0"
+ id "io.github.kobylynskyi.graphql.codegen" version "5.5.1-SNAPSHOT"
}
-def graphqlCodegenClientKotlinVersion = '5.5.0' // Variable used in the automatic release process
+def graphqlCodegenClientKotlinVersion = '5.5.1-SNAPSHOT' // Variable used in the automatic release process
group = 'io.github.dreamylost'
version = graphqlCodegenClientKotlinVersion
@@ -29,7 +29,7 @@ repositories {
dependencies {
- implementation "io.github.kobylynskyi:graphql-java-codegen:5.5.0"
+ implementation "io.github.kobylynskyi:graphql-java-codegen:5.5.1-SNAPSHOT"
implementation "javax.validation:validation-api:2.0.1.Final"
implementation "com.squareup.okhttp3:okhttp:4.2.2"
implementation "com.fasterxml.jackson.core:jackson-core:2.13.3"
diff --git a/plugins/gradle/example-client/build.gradle b/plugins/gradle/example-client/build.gradle
index 556007b93..f8943b336 100644
--- a/plugins/gradle/example-client/build.gradle
+++ b/plugins/gradle/example-client/build.gradle
@@ -7,7 +7,7 @@ plugins {
// use the latest available version:
// https://plugins.gradle.org/plugin/io.github.kobylynskyi.graphql.codegen
- id "io.github.kobylynskyi.graphql.codegen" version "5.5.0"
+ id "io.github.kobylynskyi.graphql.codegen" version "5.5.1-SNAPSHOT"
}
mainClassName = "io.github.kobylynskyi.order.Application"
@@ -22,7 +22,7 @@ dependencies {
// use the latest available version:
// https://search.maven.org/artifact/io.github.kobylynskyi/graphql-java-codegen
- implementation "io.github.kobylynskyi:graphql-java-codegen:5.5.0"
+ implementation "io.github.kobylynskyi:graphql-java-codegen:5.5.1-SNAPSHOT"
implementation "org.apache.httpcomponents:httpclient:4.5.13"
implementation "javax.validation:validation-api:2.0.1.Final"
diff --git a/plugins/gradle/example-server/build.gradle b/plugins/gradle/example-server/build.gradle
index 76487c044..6a3922f7a 100644
--- a/plugins/gradle/example-server/build.gradle
+++ b/plugins/gradle/example-server/build.gradle
@@ -6,7 +6,7 @@ plugins {
//
// use the latest available version:
// https://plugins.gradle.org/plugin/io.github.kobylynskyi.graphql.codegen
- id "io.github.kobylynskyi.graphql.codegen" version "5.5.0"
+ id "io.github.kobylynskyi.graphql.codegen" version "5.5.1-SNAPSHOT"
}
mainClassName = "io.github.kobylynskyi.product.Application"
diff --git a/plugins/gradle/graphql-java-codegen-gradle-plugin/build.gradle b/plugins/gradle/graphql-java-codegen-gradle-plugin/build.gradle
index d0382ea4a..751f0f812 100644
--- a/plugins/gradle/graphql-java-codegen-gradle-plugin/build.gradle
+++ b/plugins/gradle/graphql-java-codegen-gradle-plugin/build.gradle
@@ -16,7 +16,7 @@ apply plugin: "java"
apply plugin: "idea"
apply plugin: "maven-publish"
-def graphqlCodegenGradlePluginVersion = '5.5.0' // This variable used in the automatic release process
+def graphqlCodegenGradlePluginVersion = '5.5.1-SNAPSHOT' // This variable used in the automatic release process
group = "io.github.kobylynskyi"
version = graphqlCodegenGradlePluginVersion
diff --git a/plugins/maven/example-client/pom.xml b/plugins/maven/example-client/pom.xml
index 5233e0fb1..418c422cb 100644
--- a/plugins/maven/example-client/pom.xml
+++ b/plugins/maven/example-client/pom.xml
@@ -4,7 +4,7 @@
io.github.kobylynskyi
graphql-codegen-maven-plugin-example-client
- 5.5.0
+ 5.5.1-SNAPSHOT
graphql-codegen-maven-plugin-example-client
diff --git a/plugins/maven/example-server/pom.xml b/plugins/maven/example-server/pom.xml
index 3c5590302..5f5d85d11 100644
--- a/plugins/maven/example-server/pom.xml
+++ b/plugins/maven/example-server/pom.xml
@@ -4,7 +4,7 @@
io.github.kobylynskyi
graphql-codegen-maven-plugin-example-server
- 5.5.0
+ 5.5.1-SNAPSHOT
graphql-codegen-maven-plugin-example-server
diff --git a/plugins/maven/graphql-java-codegen-maven-plugin/pom.xml b/plugins/maven/graphql-java-codegen-maven-plugin/pom.xml
index 86fbdbd9a..ba76048c6 100644
--- a/plugins/maven/graphql-java-codegen-maven-plugin/pom.xml
+++ b/plugins/maven/graphql-java-codegen-maven-plugin/pom.xml
@@ -3,7 +3,7 @@
io.github.kobylynskyi
graphql-codegen-maven-plugin
- 5.5.0
+ 5.5.1-SNAPSHOT
maven-plugin
graphql-codegen-maven-plugin
@@ -72,7 +72,7 @@
3.0.1
3.3.4
- 5.5.0
+ 5.5.1-SNAPSHOT
diff --git a/plugins/sbt/graphql-java-codegen-sbt-plugin/src/sbt-test/graphql-codegen-sbt-plugin/example-client-scala/project/plugins.sbt b/plugins/sbt/graphql-java-codegen-sbt-plugin/src/sbt-test/graphql-codegen-sbt-plugin/example-client-scala/project/plugins.sbt
index bf73b807b..8b61a3547 100644
--- a/plugins/sbt/graphql-java-codegen-sbt-plugin/src/sbt-test/graphql-codegen-sbt-plugin/example-client-scala/project/plugins.sbt
+++ b/plugins/sbt/graphql-java-codegen-sbt-plugin/src/sbt-test/graphql-codegen-sbt-plugin/example-client-scala/project/plugins.sbt
@@ -1 +1 @@
-addSbtPlugin("io.github.jxnu-liguobin" % "graphql-codegen-sbt-plugin" % "5.5.0")
+addSbtPlugin("io.github.jxnu-liguobin" % "graphql-codegen-sbt-plugin" % "5.5.1-SNAPSHOT")
diff --git a/plugins/sbt/graphql-java-codegen-sbt-plugin/src/sbt-test/graphql-codegen-sbt-plugin/example-client-scala/version.sbt b/plugins/sbt/graphql-java-codegen-sbt-plugin/src/sbt-test/graphql-codegen-sbt-plugin/example-client-scala/version.sbt
index 0c4d8d6ff..4be577733 100644
--- a/plugins/sbt/graphql-java-codegen-sbt-plugin/src/sbt-test/graphql-codegen-sbt-plugin/example-client-scala/version.sbt
+++ b/plugins/sbt/graphql-java-codegen-sbt-plugin/src/sbt-test/graphql-codegen-sbt-plugin/example-client-scala/version.sbt
@@ -1 +1 @@
-version in ThisBuild := "5.5.0"
+version in ThisBuild := "5.5.1-SNAPSHOT"
diff --git a/plugins/sbt/graphql-java-codegen-sbt-plugin/src/sbt-test/graphql-codegen-sbt-plugin/example-client/project/plugins.sbt b/plugins/sbt/graphql-java-codegen-sbt-plugin/src/sbt-test/graphql-codegen-sbt-plugin/example-client/project/plugins.sbt
index bf73b807b..8b61a3547 100644
--- a/plugins/sbt/graphql-java-codegen-sbt-plugin/src/sbt-test/graphql-codegen-sbt-plugin/example-client/project/plugins.sbt
+++ b/plugins/sbt/graphql-java-codegen-sbt-plugin/src/sbt-test/graphql-codegen-sbt-plugin/example-client/project/plugins.sbt
@@ -1 +1 @@
-addSbtPlugin("io.github.jxnu-liguobin" % "graphql-codegen-sbt-plugin" % "5.5.0")
+addSbtPlugin("io.github.jxnu-liguobin" % "graphql-codegen-sbt-plugin" % "5.5.1-SNAPSHOT")
diff --git a/plugins/sbt/graphql-java-codegen-sbt-plugin/src/sbt-test/graphql-codegen-sbt-plugin/example-client/version.sbt b/plugins/sbt/graphql-java-codegen-sbt-plugin/src/sbt-test/graphql-codegen-sbt-plugin/example-client/version.sbt
index 0c4d8d6ff..4be577733 100644
--- a/plugins/sbt/graphql-java-codegen-sbt-plugin/src/sbt-test/graphql-codegen-sbt-plugin/example-client/version.sbt
+++ b/plugins/sbt/graphql-java-codegen-sbt-plugin/src/sbt-test/graphql-codegen-sbt-plugin/example-client/version.sbt
@@ -1 +1 @@
-version in ThisBuild := "5.5.0"
+version in ThisBuild := "5.5.1-SNAPSHOT"
diff --git a/plugins/sbt/graphql-java-codegen-sbt-plugin/src/sbt-test/graphql-codegen-sbt-plugin/simple/project/plugins.sbt b/plugins/sbt/graphql-java-codegen-sbt-plugin/src/sbt-test/graphql-codegen-sbt-plugin/simple/project/plugins.sbt
index 74a6413bb..7f80e8527 100644
--- a/plugins/sbt/graphql-java-codegen-sbt-plugin/src/sbt-test/graphql-codegen-sbt-plugin/simple/project/plugins.sbt
+++ b/plugins/sbt/graphql-java-codegen-sbt-plugin/src/sbt-test/graphql-codegen-sbt-plugin/simple/project/plugins.sbt
@@ -1,4 +1,4 @@
-sys.props.get("plugin.version").orElse(Some("5.5.0")) match {
+sys.props.get("plugin.version").orElse(Some("5.5.1-SNAPSHOT")) match {
case Some(x) => addSbtPlugin("io.github.jxnu-liguobin" % "graphql-codegen-sbt-plugin" % x)
case _ => sys.error("""|The system property 'plugin.version' is not defined.
|Specify this property using the scriptedLaunchOpts -D.""".stripMargin)
diff --git a/plugins/sbt/graphql-java-codegen-sbt-plugin/src/sbt-test/graphql-codegen-sbt-plugin/simple/version.sbt b/plugins/sbt/graphql-java-codegen-sbt-plugin/src/sbt-test/graphql-codegen-sbt-plugin/simple/version.sbt
index 0c4d8d6ff..4be577733 100644
--- a/plugins/sbt/graphql-java-codegen-sbt-plugin/src/sbt-test/graphql-codegen-sbt-plugin/simple/version.sbt
+++ b/plugins/sbt/graphql-java-codegen-sbt-plugin/src/sbt-test/graphql-codegen-sbt-plugin/simple/version.sbt
@@ -1 +1 @@
-version in ThisBuild := "5.5.0"
+version in ThisBuild := "5.5.1-SNAPSHOT"
diff --git a/plugins/sbt/graphql-java-codegen-sbt-plugin/version.sbt b/plugins/sbt/graphql-java-codegen-sbt-plugin/version.sbt
index 0c4d8d6ff..4be577733 100644
--- a/plugins/sbt/graphql-java-codegen-sbt-plugin/version.sbt
+++ b/plugins/sbt/graphql-java-codegen-sbt-plugin/version.sbt
@@ -1 +1 @@
-version in ThisBuild := "5.5.0"
+version in ThisBuild := "5.5.1-SNAPSHOT"
From ef8baafc2dd72750301f0dc5d4649dfd66bf4581 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=A2=A6=E5=A2=83=E8=BF=B7=E7=A6=BB?=
Date: Sun, 11 Sep 2022 23:29:44 +0800
Subject: [PATCH 02/25] Upgrade versions of SBT project (#1001)
Co-authored-by: Bogdan Kobylynskyi <92bogdan@gmail.com>
---
plugins/sbt/graphql-java-codegen-sbt-plugin/build.sbt | 2 +-
.../project/Publishing.scala | 2 +-
.../project/build.properties | 2 +-
.../graphql-java-codegen-sbt-plugin/project/plugins.sbt | 8 ++++----
.../io/github/dreamylost/graphql/codegen/Compat.scala | 2 +-
.../dreamylost/graphql/codegen/GraphQLCodegenKeys.scala | 9 ++++-----
.../graphql/codegen/GraphQLCodegenPlugin.scala | 4 ++--
.../graphql/codegen/ParentInterfacesConfig.scala | 4 ++--
.../dreamylost/graphql/codegen/SchemaFinderConfig.scala | 4 ++--
.../graphql/test/api/impl/GetUserQueryResolverImpl.scala | 2 +-
.../src/test/scala/test/Test.scala | 2 +-
11 files changed, 20 insertions(+), 21 deletions(-)
diff --git a/plugins/sbt/graphql-java-codegen-sbt-plugin/build.sbt b/plugins/sbt/graphql-java-codegen-sbt-plugin/build.sbt
index 880b5be96..7d62cfb62 100644
--- a/plugins/sbt/graphql-java-codegen-sbt-plugin/build.sbt
+++ b/plugins/sbt/graphql-java-codegen-sbt-plugin/build.sbt
@@ -35,7 +35,7 @@ lazy val `graphql-codegen-sbt-plugin` = Project(id = "graphql-codegen-sbt-plugin
"org.freemarker" % "freemarker" % "2.3.31",
"com.graphql-java" % "graphql-java" % "16.2",
"com.fasterxml.jackson.core" % "jackson-databind" % "2.12.1",
- "com.typesafe" % "config" % "1.4.1"
+ "com.typesafe" % "config" % "1.4.2"
),
buildInfoKeys := Seq[BuildInfoKey](name, version, sbtVersion, jValidationVersion),
buildInfoPackage := "io.github.dreamylost.graphql.codegen"
diff --git a/plugins/sbt/graphql-java-codegen-sbt-plugin/project/Publishing.scala b/plugins/sbt/graphql-java-codegen-sbt-plugin/project/Publishing.scala
index 4f2a19f0c..a9829b54b 100644
--- a/plugins/sbt/graphql-java-codegen-sbt-plugin/project/Publishing.scala
+++ b/plugins/sbt/graphql-java-codegen-sbt-plugin/project/Publishing.scala
@@ -5,7 +5,7 @@ import xerial.sbt.Sonatype.autoImport.sonatypeProfileName
/**
* sbt publish setting
*
- * @author 梦境迷离 dreamylost
+ * @author 梦境迷离
* @since 2020-07-19
* @version v1.0
*/
diff --git a/plugins/sbt/graphql-java-codegen-sbt-plugin/project/build.properties b/plugins/sbt/graphql-java-codegen-sbt-plugin/project/build.properties
index 862afa5f2..b1e589d9f 100644
--- a/plugins/sbt/graphql-java-codegen-sbt-plugin/project/build.properties
+++ b/plugins/sbt/graphql-java-codegen-sbt-plugin/project/build.properties
@@ -1 +1 @@
-sbt.version=1.4.7
\ No newline at end of file
+sbt.version=1.7.1
\ No newline at end of file
diff --git a/plugins/sbt/graphql-java-codegen-sbt-plugin/project/plugins.sbt b/plugins/sbt/graphql-java-codegen-sbt-plugin/project/plugins.sbt
index 1ac901cf6..85b9d39d9 100644
--- a/plugins/sbt/graphql-java-codegen-sbt-plugin/project/plugins.sbt
+++ b/plugins/sbt/graphql-java-codegen-sbt-plugin/project/plugins.sbt
@@ -1,5 +1,5 @@
addSbtPlugin("org.scalariform" % "sbt-scalariform" % "1.8.3")
-addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "2.3")
-addSbtPlugin("com.jsuereth" % "sbt-pgp" % "2.0.1")
-addSbtPlugin("com.github.gseitz" % "sbt-release" % "1.0.13")
-addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.10.0")
\ No newline at end of file
+addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.11.0")
+addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.9.13")
+addSbtPlugin("com.github.sbt" % "sbt-pgp" % "2.1.2")
+addSbtPlugin("com.github.gseitz" % "sbt-release" % "1.0.13")
\ No newline at end of file
diff --git a/plugins/sbt/graphql-java-codegen-sbt-plugin/src/main/scala/io/github/dreamylost/graphql/codegen/Compat.scala b/plugins/sbt/graphql-java-codegen-sbt-plugin/src/main/scala/io/github/dreamylost/graphql/codegen/Compat.scala
index 4c83b9b2e..fa589fcb5 100644
--- a/plugins/sbt/graphql-java-codegen-sbt-plugin/src/main/scala/io/github/dreamylost/graphql/codegen/Compat.scala
+++ b/plugins/sbt/graphql-java-codegen-sbt-plugin/src/main/scala/io/github/dreamylost/graphql/codegen/Compat.scala
@@ -9,7 +9,7 @@ import sbt.Configuration
/**
*
- * @author 梦境迷离 dreamylost
+ * @author 梦境迷离
* @since 2020-07-18
* @version v1.0
*/
diff --git a/plugins/sbt/graphql-java-codegen-sbt-plugin/src/main/scala/io/github/dreamylost/graphql/codegen/GraphQLCodegenKeys.scala b/plugins/sbt/graphql-java-codegen-sbt-plugin/src/main/scala/io/github/dreamylost/graphql/codegen/GraphQLCodegenKeys.scala
index a62a58f6d..da32112bd 100644
--- a/plugins/sbt/graphql-java-codegen-sbt-plugin/src/main/scala/io/github/dreamylost/graphql/codegen/GraphQLCodegenKeys.scala
+++ b/plugins/sbt/graphql-java-codegen-sbt-plugin/src/main/scala/io/github/dreamylost/graphql/codegen/GraphQLCodegenKeys.scala
@@ -2,13 +2,12 @@ package io.github.dreamylost.graphql.codegen
import java.util
-import com.kobylynskyi.graphql.codegen.model.{ ApiInterfaceStrategy, ApiNamePrefixStrategy, ApiRootInterfaceStrategy, RelayConfig }
+import com.kobylynskyi.graphql.codegen.model._
import sbt._
-import com.kobylynskyi.graphql.codegen.model.GeneratedLanguage
/**
*
- * @author liguobin@growingio.com
+ * @author 梦境迷离
* @version 1.0,2020/7/15
*/
trait GraphQLCodegenKeys {
@@ -126,11 +125,11 @@ trait GraphQLCodegenKeys {
val generateSealedInterfaces = settingKey[Boolean]("If true, generate sealed interfaces for GraphQL unions and interfaces, else generate normal interfaces.")
- val generateJacksonTypeIdResolver = settingKey[Boolean]("Specifies whether generated union interfaces should be annotated with a custom Jackson type id resolver generated in model package")
+ val generateJacksonTypeIdResolver = settingKey[Boolean]("Specifies whether generated union interfaces should be annotated with a custom Jackson type id resolver generated in model package.")
//for version
val javaxValidationApiVersion = settingKey[Option[String]]("javax-validation-api version")
- val graphqlJavaCodegenVersion = settingKey[Option[String]]("graphql java codegen version")
+ val graphqlJavaCodegenVersion = settingKey[Option[String]]("graphql-java-codegen version")
//some others for sbt
val generateCodegenTargetPath = settingKey[File]("Where to store generated files and add the generated code to the classpath, so that they can be referenced.")
diff --git a/plugins/sbt/graphql-java-codegen-sbt-plugin/src/main/scala/io/github/dreamylost/graphql/codegen/GraphQLCodegenPlugin.scala b/plugins/sbt/graphql-java-codegen-sbt-plugin/src/main/scala/io/github/dreamylost/graphql/codegen/GraphQLCodegenPlugin.scala
index 6c5a80481..52edf7fec 100644
--- a/plugins/sbt/graphql-java-codegen-sbt-plugin/src/main/scala/io/github/dreamylost/graphql/codegen/GraphQLCodegenPlugin.scala
+++ b/plugins/sbt/graphql-java-codegen-sbt-plugin/src/main/scala/io/github/dreamylost/graphql/codegen/GraphQLCodegenPlugin.scala
@@ -6,7 +6,7 @@ import com.kobylynskyi.graphql.codegen.model._
import com.kobylynskyi.graphql.codegen.model.exception.LanguageNotSupportedException
import com.kobylynskyi.graphql.codegen.model.GeneratedLanguage._
import com.kobylynskyi.graphql.codegen.scala.ScalaGraphQLCodegen
-import com.kobylynskyi.graphql.codegen.supplier.{ MergeableMappingConfigSupplier, SchemaFinder }
+import com.kobylynskyi.graphql.codegen.supplier._
import sbt.{ AutoPlugin, PluginTrigger, _ }
import sbt.Keys.{ sLog, sourceManaged, _ }
import sbt.internal.util.complete.DefaultParsers.spaceDelimited
@@ -19,7 +19,7 @@ import sbt.Def
/**
*
- * @author liguobin@growingio.com
+ * @author 梦境迷离
* @version 1.0,2020/7/15
*/
object GraphQLCodegenPlugin extends GraphQLCodegenPlugin(Compile, configurationPostfix = "-main") {
diff --git a/plugins/sbt/graphql-java-codegen-sbt-plugin/src/main/scala/io/github/dreamylost/graphql/codegen/ParentInterfacesConfig.scala b/plugins/sbt/graphql-java-codegen-sbt-plugin/src/main/scala/io/github/dreamylost/graphql/codegen/ParentInterfacesConfig.scala
index 152e9d36b..1ac52001d 100644
--- a/plugins/sbt/graphql-java-codegen-sbt-plugin/src/main/scala/io/github/dreamylost/graphql/codegen/ParentInterfacesConfig.scala
+++ b/plugins/sbt/graphql-java-codegen-sbt-plugin/src/main/scala/io/github/dreamylost/graphql/codegen/ParentInterfacesConfig.scala
@@ -2,10 +2,10 @@ package io.github.dreamylost.graphql.codegen
/**
*
- * @author liguobin@growingio.com
+ * @author 梦境迷离
* @version 1.0,2020/7/15
*/
-case class ParentInterfacesConfig(
+final case class ParentInterfacesConfig(
queryResolver: String = null,
mutationResolver: String = null,
subscriptionResolver: String = null,
diff --git a/plugins/sbt/graphql-java-codegen-sbt-plugin/src/main/scala/io/github/dreamylost/graphql/codegen/SchemaFinderConfig.scala b/plugins/sbt/graphql-java-codegen-sbt-plugin/src/main/scala/io/github/dreamylost/graphql/codegen/SchemaFinderConfig.scala
index 95b01ec27..68ba1cbd6 100644
--- a/plugins/sbt/graphql-java-codegen-sbt-plugin/src/main/scala/io/github/dreamylost/graphql/codegen/SchemaFinderConfig.scala
+++ b/plugins/sbt/graphql-java-codegen-sbt-plugin/src/main/scala/io/github/dreamylost/graphql/codegen/SchemaFinderConfig.scala
@@ -4,10 +4,10 @@ import com.kobylynskyi.graphql.codegen.supplier.SchemaFinder
/**
*
- * @author liguobin@growingio.com
+ * @author 梦境迷离
* @version 1.0,2020/7/15
*/
-case class SchemaFinderConfig(
+final case class SchemaFinderConfig(
rootDir: String,
recursive: Boolean = SchemaFinder.DEFAULT_RECURSIVE,
includePattern: String = SchemaFinder.DEFAULT_INCLUDE_PATTERN,
diff --git a/plugins/sbt/graphql-java-codegen-sbt-plugin/src/sbt-test/graphql-codegen-sbt-plugin/simple/src/main/scala/io/github/kobylynskyi/graphql/test/api/impl/GetUserQueryResolverImpl.scala b/plugins/sbt/graphql-java-codegen-sbt-plugin/src/sbt-test/graphql-codegen-sbt-plugin/simple/src/main/scala/io/github/kobylynskyi/graphql/test/api/impl/GetUserQueryResolverImpl.scala
index c4735add1..a9cbc4225 100644
--- a/plugins/sbt/graphql-java-codegen-sbt-plugin/src/sbt-test/graphql-codegen-sbt-plugin/simple/src/main/scala/io/github/kobylynskyi/graphql/test/api/impl/GetUserQueryResolverImpl.scala
+++ b/plugins/sbt/graphql-java-codegen-sbt-plugin/src/sbt-test/graphql-codegen-sbt-plugin/simple/src/main/scala/io/github/kobylynskyi/graphql/test/api/impl/GetUserQueryResolverImpl.scala
@@ -8,7 +8,7 @@ import scala.concurrent.Future
/**
* example, use a async api
*
- * @author 梦境迷离 dreamylost
+ * @author 梦境迷离
* @since 2020-07-19
* @version v1.0
*/
diff --git a/plugins/sbt/graphql-java-codegen-sbt-plugin/src/test/scala/test/Test.scala b/plugins/sbt/graphql-java-codegen-sbt-plugin/src/test/scala/test/Test.scala
index 1effb0f7f..e94859ede 100644
--- a/plugins/sbt/graphql-java-codegen-sbt-plugin/src/test/scala/test/Test.scala
+++ b/plugins/sbt/graphql-java-codegen-sbt-plugin/src/test/scala/test/Test.scala
@@ -2,7 +2,7 @@ package test
/**
*
- * @author liguobin@growingio.com
+ * @author 梦境迷离
* @version 1.0,2020/7/15
*/
object Test {
From a0d82441a57a19e681323c85dc014d740e3685d3 Mon Sep 17 00:00:00 2001
From: msl-at-fcb <96451448+msl-at-fcb@users.noreply.github.com>
Date: Tue, 13 Sep 2022 22:49:37 +1000
Subject: [PATCH 03/25] Added support for annotations in generated kotlin
operations #1002 (#1003)
---
.../templates/kotlin-lang/operations.ftl | 2 +-
.../kotlin/GraphQLCodegenGitHubTest.java | 50 ++++++++++++++++++-
...picSuggestionMutationWithAnnotation.kt.txt | 13 +++++
...icSuggestionMutationWithAnnotations.kt.txt | 13 +++++
4 files changed, 76 insertions(+), 2 deletions(-)
create mode 100644 src/test/resources/expected-classes/kt/field-resolver/AcceptTopicSuggestionMutationWithAnnotation.kt.txt
create mode 100644 src/test/resources/expected-classes/kt/field-resolver/AcceptTopicSuggestionMutationWithAnnotations.kt.txt
diff --git a/src/main/resources/templates/kotlin-lang/operations.ftl b/src/main/resources/templates/kotlin-lang/operations.ftl
index b84121916..859744daa 100755
--- a/src/main/resources/templates/kotlin-lang/operations.ftl
+++ b/src/main/resources/templates/kotlin-lang/operations.ftl
@@ -38,7 +38,7 @@ interface ${className}<#if implements?has_content> : <#list implements as interf
<#if operation.throwsException>
@Throws(Exception::class)
#if>
- fun ${operation.name}(<#list operation.parameters as param>${param.name}: ${param.type}<#if param_has_next>, #if>#list>): ${operation.type}
+ fun ${operation.name}(<#list operation.parameters as param><#list param.annotations as paramAnnotation>@${paramAnnotation}<#if param.annotations?has_content> #if>#list>${param.name}: ${param.type}<#if param_has_next>, #if>#list>): ${operation.type}
#list>
}
diff --git a/src/test/java/com/kobylynskyi/graphql/codegen/kotlin/GraphQLCodegenGitHubTest.java b/src/test/java/com/kobylynskyi/graphql/codegen/kotlin/GraphQLCodegenGitHubTest.java
index 3d3040c50..c3d92c1ab 100644
--- a/src/test/java/com/kobylynskyi/graphql/codegen/kotlin/GraphQLCodegenGitHubTest.java
+++ b/src/test/java/com/kobylynskyi/graphql/codegen/kotlin/GraphQLCodegenGitHubTest.java
@@ -12,10 +12,13 @@
import java.io.File;
import java.io.IOException;
import java.util.Collections;
+import java.util.HashSet;
import java.util.Objects;
+import java.util.Set;
import static com.kobylynskyi.graphql.codegen.TestUtils.assertSameTrimmedContent;
import static com.kobylynskyi.graphql.codegen.TestUtils.getFileByName;
+import static java.util.Collections.singleton;
import static java.util.Collections.singletonList;
import static org.hamcrest.MatcherAssert.assertThat;
@@ -188,6 +191,51 @@ void generate_CustomFieldsResolvers() throws Exception {
getFileByName(files, "AcceptTopicSuggestionPayloadResolver.kt"));
}
+ @Test
+ void generate_CustomFieldsResolversWithAnnotation() throws Exception {
+ mappingConfig.setModelNamePrefix("Github");
+ mappingConfig.setModelNameSuffix("TO");
+ mappingConfig.setApiNameSuffix("WithAnnotation");
+ mappingConfig.setResolverArgumentAnnotations(singleton("some.Annotation"));
+ mappingConfig.setGenerateDataFetchingEnvironmentArgumentInApis(true);
+ mappingConfig.setFieldsWithResolvers(Collections.singleton("AcceptTopicSuggestionPayload.topic"));
+
+ new KotlinGraphQLCodegen(singletonList("src/test/resources/schemas/github.graphqls"),
+ outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo()).generate();
+
+ File[] files = Objects.requireNonNull(outputktClassesDir.listFiles());
+
+ assertSameTrimmedContent(new File(
+ "src/test/resources/expected-classes/kt/field-resolver/" +
+ "AcceptTopicSuggestionMutationWithAnnotation.kt.txt"),
+ getFileByName(files, "AcceptTopicSuggestionMutationWithAnnotation.kt"));
+ }
+
+ @Test
+ void generate_CustomFieldsResolversWithMultipleAnnotations() throws Exception {
+
+ Set annotations = new HashSet<>();
+ annotations.add("some.Annotation");
+ annotations.add("another.Annotation");
+
+ mappingConfig.setModelNamePrefix("Github");
+ mappingConfig.setModelNameSuffix("TO");
+ mappingConfig.setApiNameSuffix("WithAnnotations");
+ mappingConfig.setResolverArgumentAnnotations(annotations);
+ mappingConfig.setGenerateDataFetchingEnvironmentArgumentInApis(true);
+ mappingConfig.setFieldsWithResolvers(Collections.singleton("AcceptTopicSuggestionPayload.topic"));
+
+ new KotlinGraphQLCodegen(singletonList("src/test/resources/schemas/github.graphqls"),
+ outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo()).generate();
+
+ File[] files = Objects.requireNonNull(outputktClassesDir.listFiles());
+
+ assertSameTrimmedContent(new File(
+ "src/test/resources/expected-classes/kt/field-resolver/" +
+ "AcceptTopicSuggestionMutationWithAnnotations.kt.txt"),
+ getFileByName(files, "AcceptTopicSuggestionMutationWithAnnotations.kt"));
+ }
+
@Test
void generate_RequestWithDefaultValue() throws Exception {
mappingConfig.setGenerateBuilder(true);
@@ -200,4 +248,4 @@ void generate_RequestWithDefaultValue() throws Exception {
getFileByName(files, "FriendsQueryRequest.kt"));
}
-}
\ No newline at end of file
+}
diff --git a/src/test/resources/expected-classes/kt/field-resolver/AcceptTopicSuggestionMutationWithAnnotation.kt.txt b/src/test/resources/expected-classes/kt/field-resolver/AcceptTopicSuggestionMutationWithAnnotation.kt.txt
new file mode 100644
index 000000000..f80fa2253
--- /dev/null
+++ b/src/test/resources/expected-classes/kt/field-resolver/AcceptTopicSuggestionMutationWithAnnotation.kt.txt
@@ -0,0 +1,13 @@
+package com.github.graphql
+
+
+@javax.annotation.Generated(
+ value = ["com.kobylynskyi.graphql.codegen.GraphQLCodegen"],
+ date = "2020-12-31T23:59:59-0500"
+)
+interface AcceptTopicSuggestionMutationWithAnnotation {
+
+ @Throws(Exception::class)
+ fun acceptTopicSuggestion(@some.Annotation input: GithubAcceptTopicSuggestionInputTO, env: graphql.schema.DataFetchingEnvironment): GithubAcceptTopicSuggestionPayloadTO?
+
+}
diff --git a/src/test/resources/expected-classes/kt/field-resolver/AcceptTopicSuggestionMutationWithAnnotations.kt.txt b/src/test/resources/expected-classes/kt/field-resolver/AcceptTopicSuggestionMutationWithAnnotations.kt.txt
new file mode 100644
index 000000000..36d4f51b4
--- /dev/null
+++ b/src/test/resources/expected-classes/kt/field-resolver/AcceptTopicSuggestionMutationWithAnnotations.kt.txt
@@ -0,0 +1,13 @@
+package com.github.graphql
+
+
+@javax.annotation.Generated(
+ value = ["com.kobylynskyi.graphql.codegen.GraphQLCodegen"],
+ date = "2020-12-31T23:59:59-0500"
+)
+interface AcceptTopicSuggestionMutationWithAnnotations {
+
+ @Throws(Exception::class)
+ fun acceptTopicSuggestion(@another.Annotation @some.Annotation input: GithubAcceptTopicSuggestionInputTO, env: graphql.schema.DataFetchingEnvironment): GithubAcceptTopicSuggestionPayloadTO?
+
+}
From ec6d30d239cdf835207ab9a0d0b4fd82a6791c64 Mon Sep 17 00:00:00 2001
From: esfomeado
Date: Sun, 19 Feb 2023 02:06:40 +0000
Subject: [PATCH 04/25] Fix failing tests on some OS (#1027)
---
.../scala/GraphQLCodegenAnnotationsTest.java | 21 ++++++++++---------
1 file changed, 11 insertions(+), 10 deletions(-)
diff --git a/src/test/java/com/kobylynskyi/graphql/codegen/scala/GraphQLCodegenAnnotationsTest.java b/src/test/java/com/kobylynskyi/graphql/codegen/scala/GraphQLCodegenAnnotationsTest.java
index f5a288791..7fe7db10b 100644
--- a/src/test/java/com/kobylynskyi/graphql/codegen/scala/GraphQLCodegenAnnotationsTest.java
+++ b/src/test/java/com/kobylynskyi/graphql/codegen/scala/GraphQLCodegenAnnotationsTest.java
@@ -58,7 +58,7 @@ void generate_CustomAnnotationMappings() throws Exception {
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
assertFileContainsElements(files, "Event.scala",
" @com.fasterxml.jackson.databind.annotation.JsonDeserialize(using = " +
- "classOf[com.example.json.DateTimeScalarDeserializer])\n" +
+ "classOf[com.example.json.DateTimeScalarDeserializer])" + System.lineSeparator() +
" createdDateTime: org.joda.time.DateTime,");
}
@@ -91,23 +91,23 @@ void generate_CustomAnnotationMappings_Class() throws Exception {
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
assertFileContainsElements(files, "AcceptTopicSuggestionInput.scala",
"@com.fasterxml.jackson.databind.annotation.JsonDeserialize(using = " +
- "classOf[AcceptTopicSuggestionInputDeserializer])\n" +
+ "classOf[AcceptTopicSuggestionInputDeserializer])" + System.lineSeparator() +
"case class AcceptTopicSuggestionInput");
assertFileContainsElements(files, "AcceptTopicSuggestionPayload.scala",
"@com.fasterxml.jackson.databind.annotation.JsonDeserialize(using = " +
- "classOf[AcceptTopicSuggestionPayloadDeserializer])\n" +
+ "classOf[AcceptTopicSuggestionPayloadDeserializer])" + System.lineSeparator() +
"case class AcceptTopicSuggestionPayload");
assertFileContainsElements(files, "Actor.scala",
"@com.fasterxml.jackson.databind.annotation.JsonDeserialize(using = " +
- "classOf[ActorDeserializer])\n" +
+ "classOf[ActorDeserializer])" + System.lineSeparator() +
"trait Actor");
assertFileContainsElements(files, "Assignee.scala",
"@com.fasterxml.jackson.databind.annotation.JsonDeserialize(using = " +
- "classOf[AssigneeDeserializer])\n" +
+ "classOf[AssigneeDeserializer])" + System.lineSeparator() +
"trait Assignee");
assertFileContainsElements(files, "DeploymentOrderField.scala",
"@com.fasterxml.jackson.databind.annotation.JsonDeserialize(using = " +
- "classOf[DeploymentOrderFieldDeserializer])\n" +
+ "classOf[DeploymentOrderFieldDeserializer])" + System.lineSeparator() +
"object DeploymentOrderField extends Enumeration");
}
@@ -128,9 +128,10 @@ void generate_CustomAnnotationMappings_Multiple() throws Exception {
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
assertFileContainsElements(files, "AcceptTopicSuggestionPayload.scala",
"@com.fasterxml.jackson.annotation.JsonTypeInfo(use = com.fasterxml.jackson" +
- ".annotation.JsonTypeInfo.Id.NAME, property = \"__typename\")\n" +
+ ".annotation.JsonTypeInfo.Id.NAME, property = \"__typename\")" + System.lineSeparator() +
"@com.fasterxml.jackson.databind.annotation.JsonTypeIdResolver(classOf[io.github" +
- ".kobylynskyi.order.external.starwars.AcceptTopicSuggestionPayloadTypeResolver])\n" +
+ ".kobylynskyi.order.external.starwars.AcceptTopicSuggestionPayloadTypeResolver])" +
+ System.lineSeparator() +
"case class AcceptTopicSuggestionPayload");
}
@@ -154,11 +155,11 @@ void generate_CustomAnnotationMappings_RequestResponseClasses() throws Exception
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
assertFileContainsElements(files, "CodeOfConductQueryRequest.scala",
"@com.fasterxml.jackson.databind.annotation.JsonDeserialize(using = " +
- "classOf[CodeOfConductQueryRequestDeserializer])\n" +
+ "classOf[CodeOfConductQueryRequestDeserializer])" + System.lineSeparator() +
"class CodeOfConductQueryRequest");
assertFileContainsElements(files, "CodeOfConductQueryResponse.scala",
"@com.fasterxml.jackson.databind.annotation.JsonDeserialize(using = " +
- "classOf[CodeOfConductQueryResponseDeserializer])\n" +
+ "classOf[CodeOfConductQueryResponseDeserializer])" + System.lineSeparator() +
"class CodeOfConductQueryResponse extends GraphQLResult[JMap[String, " +
"CodeOfConduct]]");
}
From 76e0471677c996b3ad2ec6c53fc6ba4fa4553250 Mon Sep 17 00:00:00 2001
From: Bogdan Kobylynskyi <92bogdan@gmail.com>
Date: Sun, 19 Feb 2023 20:49:41 -0500
Subject: [PATCH 05/25] Fix generation of Interface when return type of the
method has a list of Unions #1018 (#1030)
---
.../codegen/java/JavaGraphQLTypeMapper.java | 2 +-
.../codegen/mapper/GraphQLTypeMapper.java | 10 ++++++++--
.../graphql/codegen/model/MappingContext.java | 6 ++++++
.../codegen/model/NamedDefinition.java | 14 +++++++-------
.../model/definitions/ExtendedDocument.java | 6 ++++++
.../GraphQLCodegenUnionResolverTest.java | 19 ++++++++++---------
.../GraphQLCodegenUnionResolverTest.java | 19 ++++++++++---------
.../GraphQLCodegenUnionResolverTest.java | 19 ++++++++++---------
.../ResultObject.java.txt | 12 ++++++++++++
.../MyResultObjectSuffix.java.txt | 9 +++++++++
.../ResultObject.kt.txt | 12 ++++++++++++
.../MyResultObjectSuffix.kt.txt | 9 +++++++++
.../ResultObject.scala.txt | 12 ++++++++++++
.../MyResultObjectSuffix.scala.txt | 9 +++++++++
.../resources/schemas/union-resolver.graphqls | 4 ++++
15 files changed, 125 insertions(+), 37 deletions(-)
create mode 100644 src/test/resources/expected-classes/jackson-resolver-union/ResultObject.java.txt
create mode 100644 src/test/resources/expected-classes/jackson-resolver-union/without-model-package/MyResultObjectSuffix.java.txt
create mode 100644 src/test/resources/expected-classes/kt/jackson-resolver-union/ResultObject.kt.txt
create mode 100644 src/test/resources/expected-classes/kt/jackson-resolver-union/without-model-package/MyResultObjectSuffix.kt.txt
create mode 100644 src/test/resources/expected-classes/scala/jackson-resolver-union/ResultObject.scala.txt
create mode 100644 src/test/resources/expected-classes/scala/jackson-resolver-union/without-model-package/MyResultObjectSuffix.scala.txt
diff --git a/src/main/java/com/kobylynskyi/graphql/codegen/java/JavaGraphQLTypeMapper.java b/src/main/java/com/kobylynskyi/graphql/codegen/java/JavaGraphQLTypeMapper.java
index 08499e6d0..177e74fe5 100644
--- a/src/main/java/com/kobylynskyi/graphql/codegen/java/JavaGraphQLTypeMapper.java
+++ b/src/main/java/com/kobylynskyi/graphql/codegen/java/JavaGraphQLTypeMapper.java
@@ -101,7 +101,7 @@ public NamedDefinition getLanguageType(MappingContext mappingContext, String gra
serializeUsingObjectMapper = true;
}
- return new NamedDefinition(langTypeName, graphQLType, mappingContext.getInterfacesName().contains(graphQLType),
+ return new NamedDefinition(langTypeName, graphQLType, isInterfaceOrUnion(mappingContext, graphQLType),
mandatory, primitiveCanBeUsed, serializeUsingObjectMapper);
}
diff --git a/src/main/java/com/kobylynskyi/graphql/codegen/mapper/GraphQLTypeMapper.java b/src/main/java/com/kobylynskyi/graphql/codegen/mapper/GraphQLTypeMapper.java
index c2baadbdf..b83360aee 100644
--- a/src/main/java/com/kobylynskyi/graphql/codegen/mapper/GraphQLTypeMapper.java
+++ b/src/main/java/com/kobylynskyi/graphql/codegen/mapper/GraphQLTypeMapper.java
@@ -177,7 +177,8 @@ public NamedDefinition getLanguageType(MappingContext mappingContext, Type> gr
} else if (graphqlType instanceof ListType) {
NamedDefinition mappedCollectionType = getLanguageType(mappingContext, ((ListType) graphqlType).getType(),
name, parentTypeName, false, true);
- if (mappedCollectionType.isInterface() && mappingContext.getInterfacesName().contains(parentTypeName)) {
+ if (mappedCollectionType.isInterfaceOrUnion() &&
+ isInterfaceOrUnion(mappingContext, parentTypeName)) {
mappedCollectionType.setJavaName(
wrapSuperTypeIntoList(mappingContext, mappedCollectionType.getJavaName(), mandatory));
} else {
@@ -223,7 +224,7 @@ public NamedDefinition getLanguageType(MappingContext mappingContext, String gra
serializeFieldsUsingObjectMapper.contains(graphQLType) ||
serializeFieldsUsingObjectMapper.contains(parentTypeName + "." + name);
- return new NamedDefinition(langTypeName, graphQLType, mappingContext.getInterfacesName().contains(graphQLType),
+ return new NamedDefinition(langTypeName, graphQLType, isInterfaceOrUnion(mappingContext, graphQLType),
mandatory, primitiveCanBeUsed, serializeUsingObjectMapper);
}
@@ -247,4 +248,9 @@ public String getResponseReturnType(MappingContext mappingContext,
return computedTypeName;
}
+ protected boolean isInterfaceOrUnion(MappingContext mappingContext, String graphQLType) {
+ return mappingContext.getInterfacesName().contains(graphQLType) ||
+ mappingContext.getUnionsNames().contains(graphQLType);
+ }
+
}
diff --git a/src/main/java/com/kobylynskyi/graphql/codegen/model/MappingContext.java b/src/main/java/com/kobylynskyi/graphql/codegen/model/MappingContext.java
index 2bd3a17d1..557e73d6e 100644
--- a/src/main/java/com/kobylynskyi/graphql/codegen/model/MappingContext.java
+++ b/src/main/java/com/kobylynskyi/graphql/codegen/model/MappingContext.java
@@ -29,6 +29,7 @@ public class MappingContext implements GraphQLCodegenConfiguration {
private final ExtendedDocument document;
private final Set typesUnionsInterfacesNames;
private final Set interfacesName;
+ private final Set unionsName;
private final Set operationsName;
private final Map> interfaceChildren;
private final GeneratedInformation generatedInformation;
@@ -47,6 +48,7 @@ private MappingContext(File outputDirectory,
this.document = document;
this.typesUnionsInterfacesNames = document.getTypesUnionsInterfacesNames();
this.interfacesName = document.getInterfacesNames();
+ this.unionsName = document.getUnionsNames();
this.interfaceChildren = document.getInterfaceChildren();
this.generatedInformation = generatedInformation;
this.operationsName = document.getOperationsNames();
@@ -346,6 +348,10 @@ public Set getInterfacesName() {
return interfacesName;
}
+ public Set getUnionsNames() {
+ return unionsName;
+ }
+
public Set getOperationsName() {
return operationsName;
}
diff --git a/src/main/java/com/kobylynskyi/graphql/codegen/model/NamedDefinition.java b/src/main/java/com/kobylynskyi/graphql/codegen/model/NamedDefinition.java
index ab8658dde..def48a797 100644
--- a/src/main/java/com/kobylynskyi/graphql/codegen/model/NamedDefinition.java
+++ b/src/main/java/com/kobylynskyi/graphql/codegen/model/NamedDefinition.java
@@ -7,17 +7,17 @@ public class NamedDefinition {
private String javaName;
private String graphqlTypeName;
- private boolean isInterface;
+ private boolean isInterfaceOrUnion;
private boolean mandatory;
private boolean primitiveCanBeUsed;
private boolean serializeUsingObjectMapper;
public NamedDefinition(String javaName, String graphqlTypeName,
- boolean isInterface, boolean mandatory,
+ boolean isInterfaceOrUnion, boolean mandatory,
boolean primitiveCanBeUsed, boolean serializeUsingObjectMapper) {
this.javaName = javaName;
this.graphqlTypeName = graphqlTypeName;
- this.isInterface = isInterface;
+ this.isInterfaceOrUnion = isInterfaceOrUnion;
this.mandatory = mandatory;
this.primitiveCanBeUsed = primitiveCanBeUsed;
this.serializeUsingObjectMapper = serializeUsingObjectMapper;
@@ -39,12 +39,12 @@ public void setGraphqlTypeName(String graphqlTypeName) {
this.graphqlTypeName = graphqlTypeName;
}
- public boolean isInterface() {
- return isInterface;
+ public boolean isInterfaceOrUnion() {
+ return isInterfaceOrUnion;
}
- public void setInterface(boolean anInterface) {
- isInterface = anInterface;
+ public void setInterfaceOrUnion(boolean interfaceOrUnion) {
+ isInterfaceOrUnion = interfaceOrUnion;
}
public boolean isMandatory() {
diff --git a/src/main/java/com/kobylynskyi/graphql/codegen/model/definitions/ExtendedDocument.java b/src/main/java/com/kobylynskyi/graphql/codegen/model/definitions/ExtendedDocument.java
index 7a694c7dd..dbe2deb4c 100644
--- a/src/main/java/com/kobylynskyi/graphql/codegen/model/definitions/ExtendedDocument.java
+++ b/src/main/java/com/kobylynskyi/graphql/codegen/model/definitions/ExtendedDocument.java
@@ -88,6 +88,12 @@ public Set getInterfacesNames() {
.collect(Collectors.toSet());
}
+ public Set getUnionsNames() {
+ return unionDefinitions.stream()
+ .map(ExtendedDefinition::getName)
+ .collect(Collectors.toSet());
+ }
+
public Set getOperationsNames() {
return operationDefinitions.stream()
.map(ExtendedObjectTypeDefinition::getFieldDefinitions)
diff --git a/src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenUnionResolverTest.java b/src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenUnionResolverTest.java
index 97784f456..bdfbf6a1c 100644
--- a/src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenUnionResolverTest.java
+++ b/src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenUnionResolverTest.java
@@ -30,11 +30,6 @@ void init() {
mappingConfig.setGenerateJacksonTypeIdResolver(true);
}
- private List generate(String s) throws IOException {
- return new JavaGraphQLCodegen(singletonList(s), outputBuildDir, mappingConfig,
- TestUtils.getStaticGeneratedInfo()).generate();
- }
-
@AfterEach
void cleanup() {
Utils.deleteDir(outputBuildDir);
@@ -48,8 +43,8 @@ void generate_CheckFiles_with_model_package() throws Exception {
File outputJavaClassesDir = new File("build/generated/com/kobylynskyi/graphql/unionresolver");
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
List generatedFileNames = Arrays.stream(files).map(File::getName).sorted().collect(toList());
- List expectedClasses = Arrays.asList("GraphqlJacksonTypeIdResolver.java", "UnionMemberA.java",
- "UnionMemberB.java", "UnionToResolve.java");
+ List expectedClasses = Arrays.asList("GraphqlJacksonTypeIdResolver.java", "ResultObject.java",
+ "UnionMemberA.java", "UnionMemberB.java", "UnionToResolve.java");
assertEquals(expectedClasses, generatedFileNames);
for (File file : files) {
@@ -70,8 +65,8 @@ void generate_CheckFiles_without_model_package_and_with_prefix_and_suffix() thro
File outputJavaClassesDir = new File("build/generated");
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
List generatedFileNames = Arrays.stream(files).map(File::getName).sorted().collect(toList());
- List expectedClasses = Arrays.asList("GraphqlJacksonTypeIdResolver.java", "MyUnionMemberASuffix.java",
- "MyUnionMemberBSuffix.java", "MyUnionToResolveSuffix.java");
+ List expectedClasses = Arrays.asList("GraphqlJacksonTypeIdResolver.java", "MyResultObjectSuffix.java",
+ "MyUnionMemberASuffix.java", "MyUnionMemberBSuffix.java", "MyUnionToResolveSuffix.java");
assertEquals(expectedClasses, generatedFileNames);
for (File file : files) {
@@ -82,4 +77,10 @@ void generate_CheckFiles_without_model_package_and_with_prefix_and_suffix() thro
file);
}
}
+
+ private void generate(String path) throws IOException {
+ new JavaGraphQLCodegen(singletonList(path), outputBuildDir, mappingConfig,
+ TestUtils.getStaticGeneratedInfo()).generate();
+ }
+
}
diff --git a/src/test/java/com/kobylynskyi/graphql/codegen/kotlin/GraphQLCodegenUnionResolverTest.java b/src/test/java/com/kobylynskyi/graphql/codegen/kotlin/GraphQLCodegenUnionResolverTest.java
index e33c2f5ab..efe5fe257 100644
--- a/src/test/java/com/kobylynskyi/graphql/codegen/kotlin/GraphQLCodegenUnionResolverTest.java
+++ b/src/test/java/com/kobylynskyi/graphql/codegen/kotlin/GraphQLCodegenUnionResolverTest.java
@@ -32,11 +32,6 @@ void init() {
mappingConfig.setGeneratedLanguage(GeneratedLanguage.KOTLIN);
}
- private List generate(String s) throws IOException {
- return new KotlinGraphQLCodegen(singletonList(s), outputBuildDir, mappingConfig,
- TestUtils.getStaticGeneratedInfo()).generate();
- }
-
@AfterEach
void cleanup() {
Utils.deleteDir(outputBuildDir);
@@ -50,8 +45,8 @@ void generate_CheckFiles_with_model_package() throws Exception {
File outputJavaClassesDir = new File("build/generated/com/kobylynskyi/graphql/unionresolver");
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
List generatedFileNames = Arrays.stream(files).map(File::getName).sorted().collect(toList());
- List expectedClasses = Arrays.asList("GraphqlJacksonTypeIdResolver.kt", "UnionMemberA.kt",
- "UnionMemberB.kt", "UnionToResolve.kt");
+ List expectedClasses = Arrays.asList("GraphqlJacksonTypeIdResolver.kt", "ResultObject.kt",
+ "UnionMemberA.kt", "UnionMemberB.kt", "UnionToResolve.kt");
assertEquals(expectedClasses, generatedFileNames);
for (File file : files) {
@@ -72,8 +67,8 @@ void generate_CheckFiles_without_model_package_and_with_prefix_and_suffix() thro
File outputJavaClassesDir = new File("build/generated");
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
List generatedFileNames = Arrays.stream(files).map(File::getName).sorted().collect(toList());
- List expectedClasses = Arrays.asList("GraphqlJacksonTypeIdResolver.kt", "MyUnionMemberASuffix.kt",
- "MyUnionMemberBSuffix.kt", "MyUnionToResolveSuffix.kt");
+ List expectedClasses = Arrays.asList("GraphqlJacksonTypeIdResolver.kt", "MyResultObjectSuffix.kt",
+ "MyUnionMemberASuffix.kt", "MyUnionMemberBSuffix.kt", "MyUnionToResolveSuffix.kt");
assertEquals(expectedClasses, generatedFileNames);
for (File file : files) {
@@ -85,4 +80,10 @@ void generate_CheckFiles_without_model_package_and_with_prefix_and_suffix() thro
file);
}
}
+
+ private void generate(String path) throws IOException {
+ new KotlinGraphQLCodegen(singletonList(path), outputBuildDir, mappingConfig,
+ TestUtils.getStaticGeneratedInfo()).generate();
+ }
+
}
diff --git a/src/test/java/com/kobylynskyi/graphql/codegen/scala/GraphQLCodegenUnionResolverTest.java b/src/test/java/com/kobylynskyi/graphql/codegen/scala/GraphQLCodegenUnionResolverTest.java
index c585ccd0c..1efa8b065 100644
--- a/src/test/java/com/kobylynskyi/graphql/codegen/scala/GraphQLCodegenUnionResolverTest.java
+++ b/src/test/java/com/kobylynskyi/graphql/codegen/scala/GraphQLCodegenUnionResolverTest.java
@@ -32,11 +32,6 @@ void init() {
mappingConfig.setGeneratedLanguage(GeneratedLanguage.SCALA);
}
- private List generate(String s) throws IOException {
- return new ScalaGraphQLCodegen(singletonList(s), outputBuildDir, mappingConfig,
- TestUtils.getStaticGeneratedInfo()).generate();
- }
-
@AfterEach
void cleanup() {
Utils.deleteDir(outputBuildDir);
@@ -50,8 +45,8 @@ void generate_CheckFiles_with_model_package() throws Exception {
File outputJavaClassesDir = new File("build/generated/com/kobylynskyi/graphql/unionresolver");
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
List generatedFileNames = Arrays.stream(files).map(File::getName).sorted().collect(toList());
- List expectedClasses = Arrays.asList("GraphqlJacksonTypeIdResolver.scala", "UnionMemberA.scala",
- "UnionMemberB.scala", "UnionToResolve.scala");
+ List expectedClasses = Arrays.asList("GraphqlJacksonTypeIdResolver.scala", "ResultObject.scala",
+ "UnionMemberA.scala", "UnionMemberB.scala", "UnionToResolve.scala");
assertEquals(expectedClasses, generatedFileNames);
for (File file : files) {
@@ -72,8 +67,8 @@ void generate_CheckFiles_without_model_package_and_with_prefix_and_suffix() thro
File outputJavaClassesDir = new File("build/generated");
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
List generatedFileNames = Arrays.stream(files).map(File::getName).sorted().collect(toList());
- List expectedClasses = Arrays.asList("GraphqlJacksonTypeIdResolver.scala", "MyUnionMemberASuffix.scala",
- "MyUnionMemberBSuffix.scala", "MyUnionToResolveSuffix.scala");
+ List expectedClasses = Arrays.asList("GraphqlJacksonTypeIdResolver.scala", "MyResultObjectSuffix.scala",
+ "MyUnionMemberASuffix.scala", "MyUnionMemberBSuffix.scala", "MyUnionToResolveSuffix.scala");
assertEquals(expectedClasses, generatedFileNames);
for (File file : files) {
@@ -85,4 +80,10 @@ void generate_CheckFiles_without_model_package_and_with_prefix_and_suffix() thro
file);
}
}
+
+ private void generate(String path) throws IOException {
+ new ScalaGraphQLCodegen(singletonList(path), outputBuildDir, mappingConfig,
+ TestUtils.getStaticGeneratedInfo()).generate();
+ }
+
}
diff --git a/src/test/resources/expected-classes/jackson-resolver-union/ResultObject.java.txt b/src/test/resources/expected-classes/jackson-resolver-union/ResultObject.java.txt
new file mode 100644
index 000000000..a4aa0ed2d
--- /dev/null
+++ b/src/test/resources/expected-classes/jackson-resolver-union/ResultObject.java.txt
@@ -0,0 +1,12 @@
+package com.kobylynskyi.graphql.unionresolver;
+
+
+@javax.annotation.Generated(
+ value = "com.kobylynskyi.graphql.codegen.GraphQLCodegen",
+ date = "2020-12-31T23:59:59-0500"
+)
+public interface ResultObject {
+
+ java.util.List extends UnionToResolve> getList();
+
+}
\ No newline at end of file
diff --git a/src/test/resources/expected-classes/jackson-resolver-union/without-model-package/MyResultObjectSuffix.java.txt b/src/test/resources/expected-classes/jackson-resolver-union/without-model-package/MyResultObjectSuffix.java.txt
new file mode 100644
index 000000000..2ee4011e0
--- /dev/null
+++ b/src/test/resources/expected-classes/jackson-resolver-union/without-model-package/MyResultObjectSuffix.java.txt
@@ -0,0 +1,9 @@
+@javax.annotation.Generated(
+ value = "com.kobylynskyi.graphql.codegen.GraphQLCodegen",
+ date = "2020-12-31T23:59:59-0500"
+)
+public interface MyResultObjectSuffix {
+
+ java.util.List extends MyUnionToResolveSuffix> getList();
+
+}
\ No newline at end of file
diff --git a/src/test/resources/expected-classes/kt/jackson-resolver-union/ResultObject.kt.txt b/src/test/resources/expected-classes/kt/jackson-resolver-union/ResultObject.kt.txt
new file mode 100644
index 000000000..e09549ab7
--- /dev/null
+++ b/src/test/resources/expected-classes/kt/jackson-resolver-union/ResultObject.kt.txt
@@ -0,0 +1,12 @@
+package com.kobylynskyi.graphql.unionresolver
+
+
+@javax.annotation.Generated(
+ value = ["com.kobylynskyi.graphql.codegen.GraphQLCodegen"],
+ date = "2020-12-31T23:59:59-0500"
+)
+interface ResultObject {
+
+ val list: List?
+
+}
\ No newline at end of file
diff --git a/src/test/resources/expected-classes/kt/jackson-resolver-union/without-model-package/MyResultObjectSuffix.kt.txt b/src/test/resources/expected-classes/kt/jackson-resolver-union/without-model-package/MyResultObjectSuffix.kt.txt
new file mode 100644
index 000000000..71f2ad729
--- /dev/null
+++ b/src/test/resources/expected-classes/kt/jackson-resolver-union/without-model-package/MyResultObjectSuffix.kt.txt
@@ -0,0 +1,9 @@
+@javax.annotation.Generated(
+ value = ["com.kobylynskyi.graphql.codegen.GraphQLCodegen"],
+ date = "2020-12-31T23:59:59-0500"
+)
+interface MyResultObjectSuffix {
+
+ val list: List?
+
+}
\ No newline at end of file
diff --git a/src/test/resources/expected-classes/scala/jackson-resolver-union/ResultObject.scala.txt b/src/test/resources/expected-classes/scala/jackson-resolver-union/ResultObject.scala.txt
new file mode 100644
index 000000000..f9ad137de
--- /dev/null
+++ b/src/test/resources/expected-classes/scala/jackson-resolver-union/ResultObject.scala.txt
@@ -0,0 +1,12 @@
+package com.kobylynskyi.graphql.unionresolver
+
+
+@javax.annotation.Generated(
+ value = Array("com.kobylynskyi.graphql.codegen.GraphQLCodegen"),
+ date = "2020-12-31T23:59:59-0500"
+)
+trait ResultObject {
+
+ val list: scala.Seq[_ <: UnionToResolve]
+
+}
\ No newline at end of file
diff --git a/src/test/resources/expected-classes/scala/jackson-resolver-union/without-model-package/MyResultObjectSuffix.scala.txt b/src/test/resources/expected-classes/scala/jackson-resolver-union/without-model-package/MyResultObjectSuffix.scala.txt
new file mode 100644
index 000000000..19d9d82d5
--- /dev/null
+++ b/src/test/resources/expected-classes/scala/jackson-resolver-union/without-model-package/MyResultObjectSuffix.scala.txt
@@ -0,0 +1,9 @@
+@javax.annotation.Generated(
+ value = Array("com.kobylynskyi.graphql.codegen.GraphQLCodegen"),
+ date = "2020-12-31T23:59:59-0500"
+)
+trait MyResultObjectSuffix {
+
+ val list: scala.Seq[_ <: MyUnionToResolveSuffix]
+
+}
\ No newline at end of file
diff --git a/src/test/resources/schemas/union-resolver.graphqls b/src/test/resources/schemas/union-resolver.graphqls
index 914317336..2f12f328c 100644
--- a/src/test/resources/schemas/union-resolver.graphqls
+++ b/src/test/resources/schemas/union-resolver.graphqls
@@ -1,3 +1,7 @@
+interface ResultObject {
+ list: [UnionToResolve!]
+}
+
type UnionMemberA {
someField: Int
}
From b6dfc63e629558061327c4d8a86aa99a06ab48c3 Mon Sep 17 00:00:00 2001
From: esfomeado
Date: Tue, 21 Feb 2023 20:16:57 +0000
Subject: [PATCH 06/25] Generate Jackson annotations for interfaces #1033 #1034
---
.../graphql/codegen/mapper/AnnotationsMapper.java | 3 ++-
.../graphql/codegen/GraphQLCodegenTest.java | 10 +++++-----
.../jackson-resolver-union/ResultObject.java.txt | 4 +++-
.../MyResultObjectSuffix.java.txt | 4 +++-
.../kt/jackson-resolver-union/ResultObject.kt.txt | 4 +++-
.../without-model-package/MyResultObjectSuffix.kt.txt | 4 +++-
.../jackson-resolver-union/ResultObject.scala.txt | 4 +++-
.../MyResultObjectSuffix.scala.txt | 4 +++-
8 files changed, 25 insertions(+), 12 deletions(-)
diff --git a/src/main/java/com/kobylynskyi/graphql/codegen/mapper/AnnotationsMapper.java b/src/main/java/com/kobylynskyi/graphql/codegen/mapper/AnnotationsMapper.java
index ecc6a103e..fbfb2453f 100644
--- a/src/main/java/com/kobylynskyi/graphql/codegen/mapper/AnnotationsMapper.java
+++ b/src/main/java/com/kobylynskyi/graphql/codegen/mapper/AnnotationsMapper.java
@@ -8,6 +8,7 @@
import graphql.language.Argument;
import graphql.language.Directive;
import graphql.language.InputValueDefinition;
+import graphql.language.InterfaceTypeDefinition;
import graphql.language.ListType;
import graphql.language.NamedNode;
import graphql.language.NonNullType;
@@ -204,7 +205,7 @@ public List getAnnotationsForDirective(MappingContext mappingContext,
public List getJacksonTypeIdAnnotations(MappingContext mappingContext, NamedNode> def) {
List defaults = new ArrayList<>();
if (Boolean.TRUE.equals(mappingContext.getGenerateJacksonTypeIdResolver())
- && def instanceof UnionTypeDefinition) {
+ && (def instanceof UnionTypeDefinition || def instanceof InterfaceTypeDefinition)) {
defaults.add("com.fasterxml.jackson.annotation.JsonTypeInfo(use = " +
"com.fasterxml.jackson.annotation.JsonTypeInfo.Id.NAME, property = \"__typename\")");
String modelPackageName = DataModelMapper.getModelPackageName(mappingContext);
diff --git a/src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenTest.java b/src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenTest.java
index bce94a841..ce083407f 100644
--- a/src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenTest.java
+++ b/src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenTest.java
@@ -21,6 +21,7 @@
import static com.kobylynskyi.graphql.codegen.TestUtils.assertFileContainsElements;
import static com.kobylynskyi.graphql.codegen.TestUtils.assertSameTrimmedContent;
import static com.kobylynskyi.graphql.codegen.TestUtils.getFileByName;
+import static java.lang.System.lineSeparator;
import static java.util.Collections.emptyList;
import static java.util.Collections.singletonList;
import static java.util.Collections.singletonMap;
@@ -141,11 +142,10 @@ void generate_NoPackage() throws Exception {
generate("src/test/resources/schemas/test.graphqls");
File[] files = Objects.requireNonNull(outputBuildDir.listFiles());
- assertFileContainsElements(files, "Event.java", System.lineSeparator() +
- "/**" + System.lineSeparator() +
- " * An event that describes a thing that happens" + System
- .lineSeparator() +
- " */" + System.lineSeparator());
+ assertFileContainsElements(files, "Event.java", lineSeparator() +
+ "/**" + lineSeparator() +
+ " * An event that describes a thing that happens" + lineSeparator() +
+ " */" + lineSeparator());
}
@Test
diff --git a/src/test/resources/expected-classes/jackson-resolver-union/ResultObject.java.txt b/src/test/resources/expected-classes/jackson-resolver-union/ResultObject.java.txt
index a4aa0ed2d..ccaceef42 100644
--- a/src/test/resources/expected-classes/jackson-resolver-union/ResultObject.java.txt
+++ b/src/test/resources/expected-classes/jackson-resolver-union/ResultObject.java.txt
@@ -5,8 +5,10 @@ package com.kobylynskyi.graphql.unionresolver;
value = "com.kobylynskyi.graphql.codegen.GraphQLCodegen",
date = "2020-12-31T23:59:59-0500"
)
+@com.fasterxml.jackson.annotation.JsonTypeInfo(use = com.fasterxml.jackson.annotation.JsonTypeInfo.Id.NAME, property = "__typename")
+@com.fasterxml.jackson.databind.annotation.JsonTypeIdResolver(com.kobylynskyi.graphql.unionresolver.GraphqlJacksonTypeIdResolver.class)
public interface ResultObject {
java.util.List extends UnionToResolve> getList();
-}
\ No newline at end of file
+}
diff --git a/src/test/resources/expected-classes/jackson-resolver-union/without-model-package/MyResultObjectSuffix.java.txt b/src/test/resources/expected-classes/jackson-resolver-union/without-model-package/MyResultObjectSuffix.java.txt
index 2ee4011e0..4acd42053 100644
--- a/src/test/resources/expected-classes/jackson-resolver-union/without-model-package/MyResultObjectSuffix.java.txt
+++ b/src/test/resources/expected-classes/jackson-resolver-union/without-model-package/MyResultObjectSuffix.java.txt
@@ -2,8 +2,10 @@
value = "com.kobylynskyi.graphql.codegen.GraphQLCodegen",
date = "2020-12-31T23:59:59-0500"
)
+@com.fasterxml.jackson.annotation.JsonTypeInfo(use = com.fasterxml.jackson.annotation.JsonTypeInfo.Id.NAME, property = "__typename")
+@com.fasterxml.jackson.databind.annotation.JsonTypeIdResolver(GraphqlJacksonTypeIdResolver.class)
public interface MyResultObjectSuffix {
java.util.List extends MyUnionToResolveSuffix> getList();
-}
\ No newline at end of file
+}
diff --git a/src/test/resources/expected-classes/kt/jackson-resolver-union/ResultObject.kt.txt b/src/test/resources/expected-classes/kt/jackson-resolver-union/ResultObject.kt.txt
index e09549ab7..ce3847886 100644
--- a/src/test/resources/expected-classes/kt/jackson-resolver-union/ResultObject.kt.txt
+++ b/src/test/resources/expected-classes/kt/jackson-resolver-union/ResultObject.kt.txt
@@ -5,8 +5,10 @@ package com.kobylynskyi.graphql.unionresolver
value = ["com.kobylynskyi.graphql.codegen.GraphQLCodegen"],
date = "2020-12-31T23:59:59-0500"
)
+@com.fasterxml.jackson.annotation.JsonTypeInfo(use = com.fasterxml.jackson.annotation.JsonTypeInfo.Id.NAME, property = "__typename")
+@com.fasterxml.jackson.databind.annotation.JsonTypeIdResolver(com.kobylynskyi.graphql.unionresolver.GraphqlJacksonTypeIdResolver::class)
interface ResultObject {
val list: List?
-}
\ No newline at end of file
+}
diff --git a/src/test/resources/expected-classes/kt/jackson-resolver-union/without-model-package/MyResultObjectSuffix.kt.txt b/src/test/resources/expected-classes/kt/jackson-resolver-union/without-model-package/MyResultObjectSuffix.kt.txt
index 71f2ad729..a4a619cca 100644
--- a/src/test/resources/expected-classes/kt/jackson-resolver-union/without-model-package/MyResultObjectSuffix.kt.txt
+++ b/src/test/resources/expected-classes/kt/jackson-resolver-union/without-model-package/MyResultObjectSuffix.kt.txt
@@ -2,8 +2,10 @@
value = ["com.kobylynskyi.graphql.codegen.GraphQLCodegen"],
date = "2020-12-31T23:59:59-0500"
)
+@com.fasterxml.jackson.annotation.JsonTypeInfo(use = com.fasterxml.jackson.annotation.JsonTypeInfo.Id.NAME, property = "__typename")
+@com.fasterxml.jackson.databind.annotation.JsonTypeIdResolver(GraphqlJacksonTypeIdResolver::class)
interface MyResultObjectSuffix {
val list: List?
-}
\ No newline at end of file
+}
diff --git a/src/test/resources/expected-classes/scala/jackson-resolver-union/ResultObject.scala.txt b/src/test/resources/expected-classes/scala/jackson-resolver-union/ResultObject.scala.txt
index f9ad137de..7cc67ab11 100644
--- a/src/test/resources/expected-classes/scala/jackson-resolver-union/ResultObject.scala.txt
+++ b/src/test/resources/expected-classes/scala/jackson-resolver-union/ResultObject.scala.txt
@@ -5,8 +5,10 @@ package com.kobylynskyi.graphql.unionresolver
value = Array("com.kobylynskyi.graphql.codegen.GraphQLCodegen"),
date = "2020-12-31T23:59:59-0500"
)
+@com.fasterxml.jackson.annotation.JsonTypeInfo(use = com.fasterxml.jackson.annotation.JsonTypeInfo.Id.NAME, property = "__typename")
+@com.fasterxml.jackson.databind.annotation.JsonTypeIdResolver(classOf[com.kobylynskyi.graphql.unionresolver.GraphqlJacksonTypeIdResolver])
trait ResultObject {
val list: scala.Seq[_ <: UnionToResolve]
-}
\ No newline at end of file
+}
diff --git a/src/test/resources/expected-classes/scala/jackson-resolver-union/without-model-package/MyResultObjectSuffix.scala.txt b/src/test/resources/expected-classes/scala/jackson-resolver-union/without-model-package/MyResultObjectSuffix.scala.txt
index 19d9d82d5..b921de8d0 100644
--- a/src/test/resources/expected-classes/scala/jackson-resolver-union/without-model-package/MyResultObjectSuffix.scala.txt
+++ b/src/test/resources/expected-classes/scala/jackson-resolver-union/without-model-package/MyResultObjectSuffix.scala.txt
@@ -2,8 +2,10 @@
value = Array("com.kobylynskyi.graphql.codegen.GraphQLCodegen"),
date = "2020-12-31T23:59:59-0500"
)
+@com.fasterxml.jackson.annotation.JsonTypeInfo(use = com.fasterxml.jackson.annotation.JsonTypeInfo.Id.NAME, property = "__typename")
+@com.fasterxml.jackson.databind.annotation.JsonTypeIdResolver(classOf[GraphqlJacksonTypeIdResolver])
trait MyResultObjectSuffix {
val list: scala.Seq[_ <: MyUnionToResolveSuffix]
-}
\ No newline at end of file
+}
From e06d69b89f641768a408f35e290b0fa6d8813120 Mon Sep 17 00:00:00 2001
From: Bogdan Kobylynskyi <92bogdan@gmail.com>
Date: Wed, 22 Feb 2023 07:15:58 -0500
Subject: [PATCH 07/25] Ability to combine multiple response projections #985
(#1031)
---
.../graphql/GraphQLParametrizedInput.java | 2 +
.../model/graphql/GraphQLResponseField.java | 19 ++
.../graphql/GraphQLResponseProjection.java | 76 ++++++-
.../graphql/codegen/model/graphql/Pair.java | 50 +++++
.../java-lang/parametrized_input.ftl | 11 +
.../java-lang/response_projection.ftl | 18 +-
.../kotlin-lang/parametrized_input.ftl | 13 ++
.../kotlin-lang/response_projection.ftl | 14 +-
.../scala-lang/parametrized_input.ftl | 12 +
.../scala-lang/response_projection.ftl | 31 ++-
.../resources/templates/templates.properties | 0
.../GraphQLResponseProjectionTest.java | 209 ++++++++++++++++++
.../EventPropertyChildParametrizedInput.java | 7 +
.../EventPropertyParentParametrizedInput.java | 7 +
.../data/EventPropertyResponseProjection.java | 36 ++-
.../graphql/data/EventResponseProjection.java | 31 ++-
.../graphql/data/IssueResponseProjection.java | 18 +-
.../data/OrganizationResponseProjection.java | 18 +-
.../UpdateIssuePayloadResponseProjection.java | 23 +-
.../UpdateNodeUnionResponseProjection.java | 22 +-
.../empty/EventResponseProjection.java.txt | 18 +-
.../request/AssetResponseProjection.java.txt | 26 ++-
.../request/EventResponseProjection.java.txt | 28 ++-
.../ProductResponseProjection.java.txt | 32 ++-
...ultItemConnectionResponseProjection.kt.txt | 30 ++-
.../SearchResultItemResponseProjection.kt.txt | 28 ++-
.../kt/empty/EventResponseProjection.kt.txt | 14 +-
.../CharResponseProjection.kt.txt | 14 +-
.../QueryFunParametrizedInput.kt.txt | 7 +
.../QueryPrivateParametrizedInput.kt.txt | 10 +
.../LocationResponseProjection.java.txt | 26 ++-
.../VehicleResponseProjection.java.txt | 24 +-
.../ClientDataParametrizedInput.java.txt | 9 +-
.../CodeOfConductResponseProjection.java.txt | 30 ++-
...entPropertyChildParametrizedInput.java.txt | 8 +
...rametrizedInput_withoutPrimitives.java.txt | 8 +
...ntPropertyParentParametrizedInput.java.txt | 10 +-
...ParametrizedInput_withModelSuffix.java.txt | 10 +-
.../EventPropertyResponseProjection.java.txt | 36 ++-
.../request/EventResponseProjection.java.txt | 34 ++-
...ventResponseProjection.java_withoutAll.txt | 34 ++-
.../ProductLinkCodeParametrizedInput.java.txt | 7 +
.../LocationResponseProjection.java.txt | 26 ++-
...tItemConnectionResponseProjection.java.txt | 34 ++-
...earchResultItemResponseProjection.java.txt | 32 ++-
.../VehicleResponseProjection.java.txt | 24 +-
.../CharResponseProjection.java.txt | 18 +-
.../QueryCaseParametrizedInput.java.txt | 9 +-
.../QueryPrivateParametrizedInput.java.txt | 9 +
.../QueryResponseProjection.java.txt | 28 ++-
.../SynchronizedResponseProjection.java.txt | 22 +-
...ItemConnectionResponseProjection.scala.txt | 47 +++-
...archResultItemResponseProjection.scala.txt | 45 +++-
.../empty/EventResponseProjection.scala.txt | 31 ++-
.../request/AssetResponseProjection.scala.txt | 39 +++-
.../request/EventResponseProjection.scala.txt | 41 +++-
.../QueryPrivateParametrizedInput.scala.txt | 12 +
57 files changed, 1253 insertions(+), 224 deletions(-)
create mode 100644 src/main/java/com/kobylynskyi/graphql/codegen/model/graphql/Pair.java
delete mode 100644 src/main/resources/templates/templates.properties
create mode 100644 src/test/java/com/kobylynskyi/graphql/codegen/model/graphql/GraphQLResponseProjectionTest.java
diff --git a/src/main/java/com/kobylynskyi/graphql/codegen/model/graphql/GraphQLParametrizedInput.java b/src/main/java/com/kobylynskyi/graphql/codegen/model/graphql/GraphQLParametrizedInput.java
index aca3d7992..b3bbf9030 100644
--- a/src/main/java/com/kobylynskyi/graphql/codegen/model/graphql/GraphQLParametrizedInput.java
+++ b/src/main/java/com/kobylynskyi/graphql/codegen/model/graphql/GraphQLParametrizedInput.java
@@ -5,4 +5,6 @@
*/
public interface GraphQLParametrizedInput {
+ GraphQLParametrizedInput deepCopy();
+
}
diff --git a/src/main/java/com/kobylynskyi/graphql/codegen/model/graphql/GraphQLResponseField.java b/src/main/java/com/kobylynskyi/graphql/codegen/model/graphql/GraphQLResponseField.java
index e42a5099b..9ca1cad2d 100644
--- a/src/main/java/com/kobylynskyi/graphql/codegen/model/graphql/GraphQLResponseField.java
+++ b/src/main/java/com/kobylynskyi/graphql/codegen/model/graphql/GraphQLResponseField.java
@@ -86,4 +86,23 @@ public boolean equals(Object obj) {
public int hashCode() {
return Objects.hash(name, alias, parameters, projection);
}
+
+ /**
+ * Returns a clone of the instance, having a deep copy of the parameters and projection.
+ *
+ * @return a clone (deep copy)
+ */
+ public GraphQLResponseField deepCopy() {
+ GraphQLResponseField deepCopy = new GraphQLResponseField(this.name);
+ if (this.alias != null) {
+ deepCopy.alias = this.alias;
+ }
+ if (this.parameters != null) {
+ deepCopy.parameters = this.parameters.deepCopy();
+ }
+ if (this.projection != null) {
+ deepCopy.projection = this.projection.deepCopy$();
+ }
+ return deepCopy;
+ }
}
diff --git a/src/main/java/com/kobylynskyi/graphql/codegen/model/graphql/GraphQLResponseProjection.java b/src/main/java/com/kobylynskyi/graphql/codegen/model/graphql/GraphQLResponseProjection.java
index 4162b1e1b..27e95978b 100644
--- a/src/main/java/com/kobylynskyi/graphql/codegen/model/graphql/GraphQLResponseProjection.java
+++ b/src/main/java/com/kobylynskyi/graphql/codegen/model/graphql/GraphQLResponseProjection.java
@@ -1,16 +1,79 @@
package com.kobylynskyi.graphql.codegen.model.graphql;
-import java.util.ArrayList;
+import java.util.LinkedHashMap;
import java.util.List;
+import java.util.Map;
+import java.util.Objects;
import java.util.StringJoiner;
/**
- * The implementation class should basically contain the fields of the particular type which
- * should be returned back to the client.
+ * The implementation class should contain the fields of the particular type that should be returned to the client.
*/
public abstract class GraphQLResponseProjection {
- protected final List fields = new ArrayList<>();
+ /**
+ * Contains all response projection fields, where:
+ * key - is the name+alias pair (where alias is nullable)
+ * value - is GraphQLResponseField which represents the response projection field
+ */
+ protected final Map, GraphQLResponseField> fields = new LinkedHashMap<>();
+
+ protected GraphQLResponseProjection() {
+ }
+
+ protected GraphQLResponseProjection(GraphQLResponseProjection projection) {
+ if (projection == null) {
+ return;
+ }
+ projection.fields.values().forEach(this::add$);
+ }
+
+ protected GraphQLResponseProjection(List extends GraphQLResponseProjection> projections) {
+ if (projections == null) {
+ return;
+ }
+ for (GraphQLResponseProjection projection : projections) {
+ if (projection == null) {
+ continue;
+ }
+ projection.fields.values().forEach(this::add$);
+ }
+ }
+
+ @SuppressWarnings({"checkstyle:MethodName", "java:S100"})
+ public abstract GraphQLResponseProjection deepCopy$();
+
+ @SuppressWarnings({"checkstyle:MethodName", "java:S100", "java:S3824"})
+ protected void add$(GraphQLResponseField responseField) {
+ Pair nameAndAlias = new Pair<>(responseField.getName(), responseField.getAlias());
+ GraphQLResponseField existingResponseField = fields.get(nameAndAlias);
+ if (existingResponseField == null) {
+ fields.put(nameAndAlias, responseField.deepCopy());
+ return;
+ }
+
+ if (!Objects.equals(responseField.getParameters(), existingResponseField.getParameters())) {
+ throw new IllegalArgumentException(
+ String.format("Field '%s' has an argument conflict", existingResponseField.getName()));
+ }
+
+ if (responseField.getAlias() != null) {
+ existingResponseField.alias(responseField.getAlias());
+ }
+ if (responseField.getParameters() != null) {
+ existingResponseField.parameters(responseField.getParameters().deepCopy());
+ }
+ if (responseField.getProjection() != null) {
+ GraphQLResponseProjection projectionCopy = responseField.getProjection().deepCopy$();
+ if (existingResponseField.getProjection() != null) {
+ for (GraphQLResponseField field : projectionCopy.fields.values()) {
+ existingResponseField.getProjection().add$(field);
+ }
+ } else {
+ existingResponseField.projection(projectionCopy);
+ }
+ }
+ }
@Override
public String toString() {
@@ -18,7 +81,10 @@ public String toString() {
return "";
}
StringJoiner joiner = new StringJoiner(" ", "{ ", " }");
- fields.forEach(field -> joiner.add(field.toString()));
+ for (GraphQLResponseField value : fields.values()) {
+ joiner.add(value.toString());
+ }
return joiner.toString();
}
+
}
diff --git a/src/main/java/com/kobylynskyi/graphql/codegen/model/graphql/Pair.java b/src/main/java/com/kobylynskyi/graphql/codegen/model/graphql/Pair.java
new file mode 100644
index 000000000..3b9bba27e
--- /dev/null
+++ b/src/main/java/com/kobylynskyi/graphql/codegen/model/graphql/Pair.java
@@ -0,0 +1,50 @@
+package com.kobylynskyi.graphql.codegen.model.graphql;
+
+import java.util.Objects;
+
+/**
+ * Class that represents a key-value pair.
+ *
+ * @param key
+ * @param value
+ */
+public class Pair {
+
+ private final K key;
+ private final V value;
+
+ public K getKey() {
+ return key;
+ }
+
+ public V getValue() {
+ return value;
+ }
+
+ public Pair(K key, V value) {
+ this.key = key;
+ this.value = value;
+ }
+
+ @Override
+ public String toString() {
+ return key + "=" + value;
+ }
+
+ @Override
+ public int hashCode() {
+ return key.hashCode() * 13 + (value == null ? 0 : value.hashCode());
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o instanceof Pair) {
+ Pair, ?> pair = (Pair, ?>) o;
+ return Objects.equals(key, pair.key) && Objects.equals(value, pair.value);
+ }
+ return false;
+ }
+}
diff --git a/src/main/resources/templates/java-lang/parametrized_input.ftl b/src/main/resources/templates/java-lang/parametrized_input.ftl
index 3b2927154..97eb06fd2 100644
--- a/src/main/resources/templates/java-lang/parametrized_input.ftl
+++ b/src/main/resources/templates/java-lang/parametrized_input.ftl
@@ -70,6 +70,17 @@ public class ${className} implements GraphQLParametrizedInput {
#list>
#if>
+ @Override
+ public ${className} deepCopy() {
+ ${className} parametrizedInput = new ${className}();
+ <#if fields?has_content>
+ <#list fields as field>
+ parametrizedInput.${field.name}(this.${field.name});
+ #list>
+ #if>
+ return parametrizedInput;
+ }
+
<#if equalsAndHashCode>
@Override
public boolean equals(Object obj) {
diff --git a/src/main/resources/templates/java-lang/response_projection.ftl b/src/main/resources/templates/java-lang/response_projection.ftl
index 939d21ec5..7f23e48c9 100644
--- a/src/main/resources/templates/java-lang/response_projection.ftl
+++ b/src/main/resources/templates/java-lang/response_projection.ftl
@@ -8,6 +8,7 @@ import com.kobylynskyi.graphql.codegen.model.graphql.GraphQLResponseProjection;
import java.util.HashMap;
import java.util.Map;
#if>
+import java.util.List;
<#if equalsAndHashCode>
import java.util.Objects;
#if>
@@ -36,6 +37,14 @@ public class ${className} extends GraphQLResponseProjection {
public ${className}() {
}
+
+ public ${className}(${className} projection) {
+ super(projection);
+ }
+
+ public ${className}(List<${className}> projections) {
+ super(projections);
+ }
<#if fields?has_content && generateAllMethodInProjection>
public ${className} all$() {
@@ -76,7 +85,7 @@ public class ${className} extends GraphQLResponseProjection {
}
public ${className} ${field.methodName}(String alias<#if field.type?has_content>, ${field.type} subProjection#if>) {
- fields.add(new GraphQLResponseField("${field.name}").alias(alias)<#if field.type?has_content>.projection(subProjection)#if>);
+ add$(new GraphQLResponseField("${field.name}").alias(alias)<#if field.type?has_content>.projection(subProjection)#if>);
return this;
}
@@ -86,13 +95,18 @@ public class ${className} extends GraphQLResponseProjection {
}
public ${className} ${field.methodName}(String alias, ${field.parametrizedInputClassName} input<#if field.type?has_content>, ${field.type} subProjection#if>) {
- fields.add(new GraphQLResponseField("${field.name}").alias(alias).parameters(input)<#if field.type?has_content>.projection(subProjection)#if>);
+ add$(new GraphQLResponseField("${field.name}").alias(alias).parameters(input)<#if field.type?has_content>.projection(subProjection)#if>);
return this;
}
#if>
#list>
#if>
+ @Override
+ public ${className} deepCopy$() {
+ return new ${className}(this);
+ }
+
<#if equalsAndHashCode>
@Override
public boolean equals(Object obj) {
diff --git a/src/main/resources/templates/kotlin-lang/parametrized_input.ftl b/src/main/resources/templates/kotlin-lang/parametrized_input.ftl
index 7d11b654b..6057672bd 100755
--- a/src/main/resources/templates/kotlin-lang/parametrized_input.ftl
+++ b/src/main/resources/templates/kotlin-lang/parametrized_input.ftl
@@ -38,6 +38,19 @@ data class ${className}(
#if>
) : GraphQLParametrizedInput {
+ override fun deepCopy(): ${className} {
+ <#if fields?has_content>
+ return ${className}(
+ <#list fields as field>
+ this.${field.name}<#if field_has_next>,#if>
+ #list>
+ )
+ <#else>
+ return ${className}()
+ #if>
+
+ }
+
override fun toString(): String {
val joiner = StringJoiner(", ", "( ", " )")
<#list fields as field>
diff --git a/src/main/resources/templates/kotlin-lang/response_projection.ftl b/src/main/resources/templates/kotlin-lang/response_projection.ftl
index c4f501116..8c76cb09b 100755
--- a/src/main/resources/templates/kotlin-lang/response_projection.ftl
+++ b/src/main/resources/templates/kotlin-lang/response_projection.ftl
@@ -24,7 +24,13 @@ import java.util.Objects
<#list annotations as annotation>
@${annotation}
#list>
-open class ${className} : GraphQLResponseProjection() {
+open class ${className} : GraphQLResponseProjection {
+
+ constructor(): super()
+
+ constructor(projection: ${className}): super(projection)
+
+ constructor(projections: List<${className}>): super(projections)
<#if fields?has_content && generateAllMethodInProjection>
private val projectionDepthOnFields: MutableMap by lazy { mutableMapOf() }
@@ -63,7 +69,7 @@ open class ${className} : GraphQLResponseProjection() {
fun ${field.methodName}(<#if field.type?has_content>subProjection: ${field.type}#if>): ${className} = ${field.methodName}(<#if field.parametrizedInputClassName?has_content>#if>null<#if field.type?has_content>, subProjection#if>)
fun ${field.methodName}(alias: String?<#if field.type?has_content>, subProjection: ${field.type}#if>): ${className} {
- fields.add(GraphQLResponseField("${field.name}").alias(alias)<#if field.type?has_content>.projection(subProjection)#if>)
+ `add$`(GraphQLResponseField("${field.name}").alias(alias)<#if field.type?has_content>.projection(subProjection)#if>)
return this
}
@@ -71,13 +77,15 @@ open class ${className} : GraphQLResponseProjection() {
fun ${field.methodName}(input: ${field.parametrizedInputClassName}<#if field.type?has_content>, subProjection: ${field.type}#if>): ${className} = ${field.methodName}(null, input<#if field.type?has_content>, subProjection#if>)
fun ${field.methodName}(alias: String?, input: ${field.parametrizedInputClassName}<#if field.type?has_content>, subProjection: ${field.type}#if>): ${className} {
- fields.add(GraphQLResponseField("${field.name}").alias(alias).parameters(input)<#if field.type?has_content>.projection(subProjection)#if>)
+ `add$`(GraphQLResponseField("${field.name}").alias(alias).parameters(input)<#if field.type?has_content>.projection(subProjection)#if>)
return this
}
#if>
#list>
#if>
+ override fun `deepCopy$`(): ${className} = ${className}(this)
+
<#if equalsAndHashCode>
override fun equals(other: Any?): Boolean {
if (this === other) {
diff --git a/src/main/resources/templates/scala-lang/parametrized_input.ftl b/src/main/resources/templates/scala-lang/parametrized_input.ftl
index 71103289d..c6fd907a0 100644
--- a/src/main/resources/templates/scala-lang/parametrized_input.ftl
+++ b/src/main/resources/templates/scala-lang/parametrized_input.ftl
@@ -54,6 +54,18 @@ case class ${className}(
#if>
) extends GraphQLParametrizedInput {
+ override def deepCopy(): ${className} = {
+ <#if fields?has_content>
+ ${className}(
+ <#list fields as field>
+ this.${field.name}<#if field_has_next>,#if>
+ #list>
+ )
+ <#else>
+ ${className}()
+ #if>
+ }
+
override def toString(): String = {<#--There is no Option[Seq[T]], Format is not supported in the generated code, so it is very difficult to write template for this format.-->
<#if fields?has_content>
scala.Seq(<#list fields as field><#assign getMethod = ".get"><#assign asJava = ".asJava">
diff --git a/src/main/resources/templates/scala-lang/response_projection.ftl b/src/main/resources/templates/scala-lang/response_projection.ftl
index a52fa69a2..42e4c3a14 100644
--- a/src/main/resources/templates/scala-lang/response_projection.ftl
+++ b/src/main/resources/templates/scala-lang/response_projection.ftl
@@ -10,6 +10,7 @@ import java.util.Objects
<#if fields?has_content && generateAllMethodInProjection>
import scala.collection.mutable.HashMap
#if>
+import scala.collection.JavaConverters._
<#if javaDoc?has_content>
/**
@@ -27,7 +28,29 @@ import scala.collection.mutable.HashMap
<#list annotations as annotation>
@${annotation}
#list>
-class ${className} extends GraphQLResponseProjection {
+class ${className}() extends GraphQLResponseProjection() {
+
+ def this(projection: ${className}) = {
+ this()
+ if (projection != null) {
+ for (field <- projection.fields.values.asScala) {
+ add$(field)
+ }
+ }
+ }
+
+ def this(projections: scala.Seq[${className}]) = {
+ this()
+ if (projections != null) {
+ for (projection <- projections) {
+ if (projection != null) {
+ for (field <- projection.fields.values.asScala) {
+ add$(field)
+ }
+ }
+ }
+ }
+ }
<#if fields?has_content && generateAllMethodInProjection>
private final lazy val projectionDepthOnFields = new HashMap[String, Int]
@@ -68,7 +91,7 @@ class ${className} extends GraphQLResponseProjection {
}
def ${field.methodName}(alias: String<#if field.type?has_content>, subProjection: ${field.type}#if>): ${className} = {
- fields.add(new GraphQLResponseField("${field.name}").alias(alias)<#if field.type?has_content>.projection(subProjection)#if>)
+ add$(new GraphQLResponseField("${field.name}").alias(alias)<#if field.type?has_content>.projection(subProjection)#if>)
this
}
@@ -78,13 +101,15 @@ class ${className} extends GraphQLResponseProjection {
}
def ${field.methodName}(alias: String, input: ${field.parametrizedInputClassName} <#if field.type?has_content>, subProjection: ${field.type}#if>): ${className} = {
- fields.add(new GraphQLResponseField("${field.name}").alias(alias).parameters(input)<#if field.type?has_content>.projection(subProjection)#if>)
+ add$(new GraphQLResponseField("${field.name}").alias(alias).parameters(input)<#if field.type?has_content>.projection(subProjection)#if>)
this
}
#if>
#list>
#if>
+ override def deepCopy$(): ${className} = new ${className}(this)
+
<#if equalsAndHashCode>
override def equals(obj: Any): Boolean = {
if (this == obj) {
diff --git a/src/main/resources/templates/templates.properties b/src/main/resources/templates/templates.properties
deleted file mode 100644
index e69de29bb..000000000
diff --git a/src/test/java/com/kobylynskyi/graphql/codegen/model/graphql/GraphQLResponseProjectionTest.java b/src/test/java/com/kobylynskyi/graphql/codegen/model/graphql/GraphQLResponseProjectionTest.java
new file mode 100644
index 000000000..67335f8c6
--- /dev/null
+++ b/src/test/java/com/kobylynskyi/graphql/codegen/model/graphql/GraphQLResponseProjectionTest.java
@@ -0,0 +1,209 @@
+package com.kobylynskyi.graphql.codegen.model.graphql;
+
+import com.kobylynskyi.graphql.codegen.model.graphql.data.EventPropertyChildParametrizedInput;
+import com.kobylynskyi.graphql.codegen.model.graphql.data.EventPropertyResponseProjection;
+import com.kobylynskyi.graphql.codegen.model.graphql.data.EventResponseProjection;
+import org.junit.jupiter.api.Test;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import static java.util.Arrays.asList;
+import static java.util.Collections.singletonList;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
+
+class GraphQLResponseProjectionTest {
+
+ @Test
+ public void deepCopy_empty() {
+ EventResponseProjection original = new EventResponseProjection();
+ EventResponseProjection deepCopy = original.deepCopy$();
+ assertTrue(deepCopy.fields.isEmpty());
+ }
+
+ @Test
+ public void deepCopy_null() {
+ assertTrue(new EventResponseProjection((EventResponseProjection) null).fields.isEmpty());
+ }
+
+ @Test
+ public void deepCopy_null_list() {
+ assertTrue(new EventResponseProjection((List) null).fields.isEmpty());
+ }
+
+ @Test
+ public void deepCopy_empty_list() {
+ assertTrue(new EventResponseProjection(new ArrayList<>()).fields.isEmpty());
+ }
+
+ @Test
+ public void deepCopy_list_with_null_element() {
+ assertTrue(new EventResponseProjection(new ArrayList<>(singletonList(null))).fields.isEmpty());
+ }
+
+ @Test
+ public void deepCopy() {
+ EventResponseProjection original = new EventResponseProjection();
+ original.id();
+ original.status("state");
+ original.properties(new EventPropertyResponseProjection()
+ .intVal()
+ .stringVal()
+ .child(new EventPropertyChildParametrizedInput(1, 2),
+ new EventPropertyResponseProjection()
+ .booleanVal()));
+
+ EventResponseProjection deepCopy = original.deepCopy$();
+
+ assertEquals("{ id state : status properties { intVal stringVal child (first: 1, last: 2) { booleanVal } } }",
+ original.toString());
+ assertEquals("{ id state : status properties { intVal stringVal child (first: 1, last: 2) { booleanVal } } }",
+ deepCopy.toString());
+
+ // check that original and deepcopy are not modified
+
+ original.active();
+ deepCopy.rating();
+
+ assertEquals(
+ "{ id state : status properties { intVal stringVal child (first: 1, last: 2) { booleanVal } } active }",
+ original.toString());
+ assertEquals(
+ "{ id state : status properties { intVal stringVal child (first: 1, last: 2) { booleanVal } } rating }",
+ deepCopy.toString());
+ }
+
+ @Test
+ public void join() {
+ EventResponseProjection projection1 = new EventResponseProjection();
+ projection1.id();
+ projection1.status("state");
+ projection1.rating();
+ projection1.properties(new EventPropertyResponseProjection()
+ .intVal()
+ .stringVal()
+ .child("child12", new EventPropertyChildParametrizedInput(1, 2),
+ new EventPropertyResponseProjection()
+ .booleanVal()));
+
+ EventResponseProjection projection2 = new EventResponseProjection();
+ projection2.id("uid");
+ projection2.status();
+ projection2.active();
+ projection2.properties(new EventPropertyResponseProjection()
+ .floatVal()
+ .child("child34", new EventPropertyChildParametrizedInput(3, 4),
+ new EventPropertyResponseProjection()
+ .intVal()));
+
+ EventResponseProjection projection12 = new EventResponseProjection(asList(projection1, projection2));
+ assertEquals("{ id state : status rating " +
+ "properties { intVal stringVal child12 : child (first: 1, last: 2) { booleanVal } " +
+ "floatVal child34 : child (first: 3, last: 4) { intVal } } uid : id status active }",
+ projection12.toString());
+ }
+
+ @Test
+ public void join_same_aliases_different_inputs() {
+ EventResponseProjection projection1 = new EventResponseProjection()
+ .properties(new EventPropertyResponseProjection()
+ .child(new EventPropertyChildParametrizedInput(1, 2),
+ new EventPropertyResponseProjection().intVal()));
+
+ EventResponseProjection projection2 = new EventResponseProjection()
+ .properties(new EventPropertyResponseProjection()
+ .child(new EventPropertyChildParametrizedInput(3, 4),
+ new EventPropertyResponseProjection().intVal()));
+
+ try {
+ new EventResponseProjection(asList(projection1, projection2));
+ fail();
+ } catch (IllegalArgumentException e) {
+ assertEquals("Field 'child' has an argument conflict", e.getMessage());
+ }
+ }
+
+ @Test
+ public void join_same_aliases_different_inputs2() {
+ EventResponseProjection projection1 = new EventResponseProjection()
+ .properties(new EventPropertyResponseProjection()
+ .child("children", new EventPropertyChildParametrizedInput(1, 2),
+ new EventPropertyResponseProjection().intVal()));
+
+ EventResponseProjection projection2 = new EventResponseProjection()
+ .properties(new EventPropertyResponseProjection()
+ .child("children", new EventPropertyChildParametrizedInput(3, 4),
+ new EventPropertyResponseProjection().intVal()));
+
+ try {
+ new EventResponseProjection(asList(projection1, projection2));
+ fail();
+ } catch (IllegalArgumentException e) {
+ assertEquals("Field 'child' has an argument conflict", e.getMessage());
+ }
+ }
+
+ @Test
+ public void join_same_aliases_different_inputs3() {
+ EventResponseProjection projection1 = new EventResponseProjection()
+ .properties(new EventPropertyResponseProjection()
+ .child("children", new EventPropertyChildParametrizedInput(1, 2),
+ null));
+
+ EventResponseProjection projection2 = new EventResponseProjection()
+ .properties(new EventPropertyResponseProjection()
+ .child("children", new EventPropertyChildParametrizedInput(3, 4),
+ new EventPropertyResponseProjection().intVal()));
+
+ try {
+ new EventResponseProjection(asList(projection1, projection2));
+ fail();
+ } catch (IllegalArgumentException e) {
+ assertEquals("Field 'child' has an argument conflict", e.getMessage());
+ }
+ }
+
+ @Test
+ public void join_same_aliases_different_inputs4() {
+ EventResponseProjection projection1 = new EventResponseProjection()
+ .properties(new EventPropertyResponseProjection()
+ .child("children", new EventPropertyChildParametrizedInput(1, 2),
+ new EventPropertyResponseProjection().intVal()));
+
+ EventResponseProjection projection2 = new EventResponseProjection()
+ .properties(new EventPropertyResponseProjection()
+ .child("children", new EventPropertyChildParametrizedInput(3, 4),
+ null));
+
+ try {
+ new EventResponseProjection(asList(projection1, projection2));
+ fail();
+ } catch (IllegalArgumentException e) {
+ assertEquals("Field 'child' has an argument conflict", e.getMessage());
+ }
+ }
+
+ @Test
+ public void join_null_values() {
+ EventResponseProjection projection1 = new EventResponseProjection();
+ projection1.id(null);
+ projection1.properties(null);
+
+ EventResponseProjection projection2 = new EventResponseProjection();
+ projection2.properties(new EventPropertyResponseProjection()
+ .child(null));
+
+ EventResponseProjection projection3 = new EventResponseProjection();
+ projection2.properties(new EventPropertyResponseProjection()
+ .child(null, null, new EventPropertyResponseProjection()
+ .child(null)));
+
+ EventResponseProjection projection123 = new EventResponseProjection(
+ asList(projection1, projection2, projection3));
+ assertEquals("{ id properties { child { child } } }",
+ projection123.toString());
+ }
+
+}
\ No newline at end of file
diff --git a/src/test/java/com/kobylynskyi/graphql/codegen/model/graphql/data/EventPropertyChildParametrizedInput.java b/src/test/java/com/kobylynskyi/graphql/codegen/model/graphql/data/EventPropertyChildParametrizedInput.java
index b8a4f6f26..2179eff54 100644
--- a/src/test/java/com/kobylynskyi/graphql/codegen/model/graphql/data/EventPropertyChildParametrizedInput.java
+++ b/src/test/java/com/kobylynskyi/graphql/codegen/model/graphql/data/EventPropertyChildParametrizedInput.java
@@ -62,4 +62,11 @@ public String toString() {
return joiner.toString();
}
+ @Override
+ public EventPropertyChildParametrizedInput deepCopy() {
+ EventPropertyChildParametrizedInput parametrizedInput = new EventPropertyChildParametrizedInput();
+ parametrizedInput.first(this.first);
+ parametrizedInput.last(this.last);
+ return parametrizedInput;
+ }
}
\ No newline at end of file
diff --git a/src/test/java/com/kobylynskyi/graphql/codegen/model/graphql/data/EventPropertyParentParametrizedInput.java b/src/test/java/com/kobylynskyi/graphql/codegen/model/graphql/data/EventPropertyParentParametrizedInput.java
index c07845db8..5f40cb22c 100644
--- a/src/test/java/com/kobylynskyi/graphql/codegen/model/graphql/data/EventPropertyParentParametrizedInput.java
+++ b/src/test/java/com/kobylynskyi/graphql/codegen/model/graphql/data/EventPropertyParentParametrizedInput.java
@@ -62,4 +62,11 @@ public String toString() {
return joiner.toString();
}
+ @Override
+ public EventPropertyParentParametrizedInput deepCopy() {
+ EventPropertyParentParametrizedInput parametrizedInput = new EventPropertyParentParametrizedInput();
+ parametrizedInput.withStatus(this.withStatus);
+ parametrizedInput.createdAfter(this.createdAfter);
+ return parametrizedInput;
+ }
}
diff --git a/src/test/java/com/kobylynskyi/graphql/codegen/model/graphql/data/EventPropertyResponseProjection.java b/src/test/java/com/kobylynskyi/graphql/codegen/model/graphql/data/EventPropertyResponseProjection.java
index 16eefa0b7..12b64815f 100644
--- a/src/test/java/com/kobylynskyi/graphql/codegen/model/graphql/data/EventPropertyResponseProjection.java
+++ b/src/test/java/com/kobylynskyi/graphql/codegen/model/graphql/data/EventPropertyResponseProjection.java
@@ -3,12 +3,27 @@
import com.kobylynskyi.graphql.codegen.model.graphql.GraphQLResponseField;
import com.kobylynskyi.graphql.codegen.model.graphql.GraphQLResponseProjection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
/**
* Response projection for EventProperty
*/
public class EventPropertyResponseProjection extends GraphQLResponseProjection {
+ private final Map projectionDepthOnFields = new HashMap<>();
+
public EventPropertyResponseProjection() {
+ super();
+ }
+
+ public EventPropertyResponseProjection(EventPropertyResponseProjection projection) {
+ super(projection);
+ }
+
+ public EventPropertyResponseProjection(List projections) {
+ super(projections);
}
public EventPropertyResponseProjection floatVal() {
@@ -16,7 +31,7 @@ public EventPropertyResponseProjection floatVal() {
}
public EventPropertyResponseProjection floatVal(String alias) {
- fields.add(new GraphQLResponseField("floatVal").alias(alias));
+ add$(new GraphQLResponseField("floatVal").alias(alias));
return this;
}
@@ -25,7 +40,7 @@ public EventPropertyResponseProjection booleanVal() {
}
public EventPropertyResponseProjection booleanVal(String alias) {
- fields.add(new GraphQLResponseField("booleanVal").alias(alias));
+ add$(new GraphQLResponseField("booleanVal").alias(alias));
return this;
}
@@ -34,7 +49,7 @@ public EventPropertyResponseProjection intVal() {
}
public EventPropertyResponseProjection intVal(String alias) {
- fields.add(new GraphQLResponseField("intVal").alias(alias));
+ add$(new GraphQLResponseField("intVal").alias(alias));
return this;
}
@@ -43,7 +58,7 @@ public EventPropertyResponseProjection stringVal() {
}
public EventPropertyResponseProjection stringVal(String alias) {
- fields.add(new GraphQLResponseField("stringVal").alias(alias));
+ add$(new GraphQLResponseField("stringVal").alias(alias));
return this;
}
@@ -52,7 +67,7 @@ public EventPropertyResponseProjection child(EventPropertyResponseProjection sub
}
public EventPropertyResponseProjection child(String alias, EventPropertyResponseProjection subProjection) {
- fields.add(new GraphQLResponseField("child").alias(alias).projection(subProjection));
+ add$(new GraphQLResponseField("child").alias(alias).projection(subProjection));
return this;
}
@@ -63,7 +78,7 @@ public EventPropertyResponseProjection child(EventPropertyChildParametrizedInput
public EventPropertyResponseProjection child(String alias, EventPropertyChildParametrizedInput input,
EventPropertyResponseProjection subProjection) {
- fields.add(new GraphQLResponseField("child").alias(alias).parameters(input).projection(subProjection));
+ add$(new GraphQLResponseField("child").alias(alias).parameters(input).projection(subProjection));
return this;
}
@@ -72,7 +87,7 @@ public EventPropertyResponseProjection parent(EventResponseProjection subProject
}
public EventPropertyResponseProjection parent(String alias, EventResponseProjection subProjection) {
- fields.add(new GraphQLResponseField("parent").alias(alias).projection(subProjection));
+ add$(new GraphQLResponseField("parent").alias(alias).projection(subProjection));
return this;
}
@@ -83,7 +98,7 @@ public EventPropertyResponseProjection parent(EventPropertyParentParametrizedInp
public EventPropertyResponseProjection parent(String alias, EventPropertyParentParametrizedInput input,
EventResponseProjection subProjection) {
- fields.add(new GraphQLResponseField("parent").alias(alias).parameters(input).projection(subProjection));
+ add$(new GraphQLResponseField("parent").alias(alias).parameters(input).projection(subProjection));
return this;
}
@@ -94,4 +109,9 @@ public EventPropertyResponseProjection parent(String alias, EventPropertyParentP
public GraphQLResponseProjection all$(int maxDepth) {
return null;
}
+
+ @Override
+ public GraphQLResponseProjection deepCopy$() {
+ return new EventPropertyResponseProjection(this);
+ }
}
diff --git a/src/test/java/com/kobylynskyi/graphql/codegen/model/graphql/data/EventResponseProjection.java b/src/test/java/com/kobylynskyi/graphql/codegen/model/graphql/data/EventResponseProjection.java
index e45a94cef..f7693102a 100644
--- a/src/test/java/com/kobylynskyi/graphql/codegen/model/graphql/data/EventResponseProjection.java
+++ b/src/test/java/com/kobylynskyi/graphql/codegen/model/graphql/data/EventResponseProjection.java
@@ -3,6 +3,8 @@
import com.kobylynskyi.graphql.codegen.model.graphql.GraphQLResponseField;
import com.kobylynskyi.graphql.codegen.model.graphql.GraphQLResponseProjection;
+import java.util.List;
+
/**
* Response projection for Event
*/
@@ -11,12 +13,20 @@ public class EventResponseProjection extends GraphQLResponseProjection {
public EventResponseProjection() {
}
+ public EventResponseProjection(EventResponseProjection projection) {
+ super(projection);
+ }
+
+ public EventResponseProjection(List projections) {
+ super(projections);
+ }
+
public EventResponseProjection id() {
return id(null);
}
public EventResponseProjection id(String alias) {
- fields.add(new GraphQLResponseField("id").alias(alias));
+ add$(new GraphQLResponseField("id").alias(alias));
return this;
}
@@ -25,7 +35,7 @@ public EventResponseProjection categoryId() {
}
public EventResponseProjection categoryId(String alias) {
- fields.add(new GraphQLResponseField("categoryId").alias(alias));
+ add$(new GraphQLResponseField("categoryId").alias(alias));
return this;
}
@@ -34,7 +44,7 @@ public EventResponseProjection properties(EventPropertyResponseProjection subPro
}
public EventResponseProjection properties(String alias, EventPropertyResponseProjection subProjection) {
- fields.add(new GraphQLResponseField("properties").alias(alias).projection(subProjection));
+ add$(new GraphQLResponseField("properties").alias(alias).projection(subProjection));
return this;
}
@@ -43,7 +53,7 @@ public EventResponseProjection status() {
}
public EventResponseProjection status(String alias) {
- fields.add(new GraphQLResponseField("status").alias(alias));
+ add$(new GraphQLResponseField("status").alias(alias));
return this;
}
@@ -52,7 +62,7 @@ public EventResponseProjection createdBy() {
}
public EventResponseProjection createdBy(String alias) {
- fields.add(new GraphQLResponseField("createdBy").alias(alias));
+ add$(new GraphQLResponseField("createdBy").alias(alias));
return this;
}
@@ -61,7 +71,7 @@ public EventResponseProjection createdDateTime() {
}
public EventResponseProjection createdDateTime(String alias) {
- fields.add(new GraphQLResponseField("createdDateTime").alias(alias));
+ add$(new GraphQLResponseField("createdDateTime").alias(alias));
return this;
}
@@ -70,7 +80,7 @@ public EventResponseProjection active() {
}
public EventResponseProjection active(String alias) {
- fields.add(new GraphQLResponseField("active").alias(alias));
+ add$(new GraphQLResponseField("active").alias(alias));
return this;
}
@@ -79,7 +89,7 @@ public EventResponseProjection rating() {
}
public EventResponseProjection rating(String alias) {
- fields.add(new GraphQLResponseField("rating").alias(alias));
+ add$(new GraphQLResponseField("rating").alias(alias));
return this;
}
@@ -90,4 +100,9 @@ public EventResponseProjection rating(String alias) {
public GraphQLResponseProjection all$(int maxDepth) {
return null;
}
+
+ @Override
+ public EventResponseProjection deepCopy$() {
+ return new EventResponseProjection(this);
+ }
}
diff --git a/src/test/java/com/kobylynskyi/graphql/codegen/model/graphql/data/IssueResponseProjection.java b/src/test/java/com/kobylynskyi/graphql/codegen/model/graphql/data/IssueResponseProjection.java
index ff698abab..ddaa5cc9e 100644
--- a/src/test/java/com/kobylynskyi/graphql/codegen/model/graphql/data/IssueResponseProjection.java
+++ b/src/test/java/com/kobylynskyi/graphql/codegen/model/graphql/data/IssueResponseProjection.java
@@ -3,17 +3,27 @@
import com.kobylynskyi.graphql.codegen.model.graphql.GraphQLResponseField;
import com.kobylynskyi.graphql.codegen.model.graphql.GraphQLResponseProjection;
+import java.util.List;
+
public class IssueResponseProjection extends GraphQLResponseProjection {
public IssueResponseProjection() {
}
+ public IssueResponseProjection(IssueResponseProjection projection) {
+ super(projection);
+ }
+
+ public IssueResponseProjection(List projections) {
+ super(projections);
+ }
+
public IssueResponseProjection activeLockReason() {
return activeLockReason(null);
}
public IssueResponseProjection activeLockReason(String alias) {
- fields.add(new GraphQLResponseField("activeLockReason").alias(alias));
+ add$(new GraphQLResponseField("activeLockReason").alias(alias));
return this;
}
@@ -24,6 +34,12 @@ public IssueResponseProjection activeLockReason(String alias) {
public GraphQLResponseProjection all$(int maxDepth) {
return null;
}
+
+ @Override
+ public IssueResponseProjection deepCopy$() {
+ return new IssueResponseProjection(this);
+ }
+
// REST OF THE STUFF WAS REMOVED
}
diff --git a/src/test/java/com/kobylynskyi/graphql/codegen/model/graphql/data/OrganizationResponseProjection.java b/src/test/java/com/kobylynskyi/graphql/codegen/model/graphql/data/OrganizationResponseProjection.java
index a7340e2c3..29e0cdc02 100644
--- a/src/test/java/com/kobylynskyi/graphql/codegen/model/graphql/data/OrganizationResponseProjection.java
+++ b/src/test/java/com/kobylynskyi/graphql/codegen/model/graphql/data/OrganizationResponseProjection.java
@@ -3,17 +3,27 @@
import com.kobylynskyi.graphql.codegen.model.graphql.GraphQLResponseField;
import com.kobylynskyi.graphql.codegen.model.graphql.GraphQLResponseProjection;
+import java.util.List;
+
public class OrganizationResponseProjection extends GraphQLResponseProjection {
public OrganizationResponseProjection() {
}
+ public OrganizationResponseProjection(OrganizationResponseProjection projection) {
+ super(projection);
+ }
+
+ public OrganizationResponseProjection(List projections) {
+ super(projections);
+ }
+
public OrganizationResponseProjection name() {
return name(null);
}
public OrganizationResponseProjection name(String alias) {
- fields.add(new GraphQLResponseField("name").alias(alias));
+ add$(new GraphQLResponseField("name").alias(alias));
return this;
}
@@ -24,6 +34,12 @@ public OrganizationResponseProjection name(String alias) {
public GraphQLResponseProjection all$(int maxDepth) {
return null;
}
+
+ @Override
+ public GraphQLResponseProjection deepCopy$() {
+ return new OrganizationResponseProjection(this);
+ }
+
// REST OF THE STUFF WAS REMOVED
}
diff --git a/src/test/java/com/kobylynskyi/graphql/codegen/model/graphql/data/UpdateIssuePayloadResponseProjection.java b/src/test/java/com/kobylynskyi/graphql/codegen/model/graphql/data/UpdateIssuePayloadResponseProjection.java
index b59f0e878..f8481e02e 100644
--- a/src/test/java/com/kobylynskyi/graphql/codegen/model/graphql/data/UpdateIssuePayloadResponseProjection.java
+++ b/src/test/java/com/kobylynskyi/graphql/codegen/model/graphql/data/UpdateIssuePayloadResponseProjection.java
@@ -3,17 +3,27 @@
import com.kobylynskyi.graphql.codegen.model.graphql.GraphQLResponseField;
import com.kobylynskyi.graphql.codegen.model.graphql.GraphQLResponseProjection;
+import java.util.List;
+
public class UpdateIssuePayloadResponseProjection extends GraphQLResponseProjection {
public UpdateIssuePayloadResponseProjection() {
}
+ public UpdateIssuePayloadResponseProjection(UpdateIssuePayloadResponseProjection projection) {
+ super(projection);
+ }
+
+ public UpdateIssuePayloadResponseProjection(List projections) {
+ super(projections);
+ }
+
public UpdateIssuePayloadResponseProjection clientMutationId() {
return clientMutationId(null);
}
public UpdateIssuePayloadResponseProjection clientMutationId(String alias) {
- fields.add(new GraphQLResponseField("clientMutationId").alias(alias));
+ add$(new GraphQLResponseField("clientMutationId").alias(alias));
return this;
}
@@ -22,7 +32,7 @@ public UpdateIssuePayloadResponseProjection issue(IssueResponseProjection subPro
}
public UpdateIssuePayloadResponseProjection issue(String alias, IssueResponseProjection subProjection) {
- fields.add(new GraphQLResponseField("issue").alias(alias).projection(subProjection));
+ add$(new GraphQLResponseField("issue").alias(alias).projection(subProjection));
return this;
}
@@ -31,7 +41,7 @@ public UpdateIssuePayloadResponseProjection union(UpdateNodeUnionResponseProject
}
public UpdateIssuePayloadResponseProjection union(String alias, UpdateNodeUnionResponseProjection subProjection) {
- fields.add(new GraphQLResponseField("union").alias(alias).projection(subProjection));
+ add$(new GraphQLResponseField("union").alias(alias).projection(subProjection));
return this;
}
@@ -42,4 +52,11 @@ public UpdateIssuePayloadResponseProjection union(String alias, UpdateNodeUnionR
public GraphQLResponseProjection all$(int maxDepth) {
return null;
}
+
+
+ @Override
+ public UpdateIssuePayloadResponseProjection deepCopy$() {
+ return new UpdateIssuePayloadResponseProjection(this);
+ }
+
}
diff --git a/src/test/java/com/kobylynskyi/graphql/codegen/model/graphql/data/UpdateNodeUnionResponseProjection.java b/src/test/java/com/kobylynskyi/graphql/codegen/model/graphql/data/UpdateNodeUnionResponseProjection.java
index df12f818e..447f983f8 100644
--- a/src/test/java/com/kobylynskyi/graphql/codegen/model/graphql/data/UpdateNodeUnionResponseProjection.java
+++ b/src/test/java/com/kobylynskyi/graphql/codegen/model/graphql/data/UpdateNodeUnionResponseProjection.java
@@ -3,6 +3,8 @@
import com.kobylynskyi.graphql.codegen.model.graphql.GraphQLResponseField;
import com.kobylynskyi.graphql.codegen.model.graphql.GraphQLResponseProjection;
+import java.util.List;
+
/**
* Response projection for SearchResultItem
*/
@@ -11,12 +13,20 @@ public class UpdateNodeUnionResponseProjection extends GraphQLResponseProjection
public UpdateNodeUnionResponseProjection() {
}
+ public UpdateNodeUnionResponseProjection(UpdateNodeUnionResponseProjection projection) {
+ super(projection);
+ }
+
+ public UpdateNodeUnionResponseProjection(List projections) {
+ super(projections);
+ }
+
public UpdateNodeUnionResponseProjection onIssue(IssueResponseProjection subProjection) {
return onIssue(null, subProjection);
}
public UpdateNodeUnionResponseProjection onIssue(String alias, IssueResponseProjection subProjection) {
- fields.add(new GraphQLResponseField("...on Issue").alias(alias).projection(subProjection));
+ add$(new GraphQLResponseField("...on Issue").alias(alias).projection(subProjection));
return this;
}
@@ -26,7 +36,7 @@ public UpdateNodeUnionResponseProjection onOrganization(OrganizationResponseProj
public UpdateNodeUnionResponseProjection onOrganization(String alias,
OrganizationResponseProjection subProjection) {
- fields.add(new GraphQLResponseField("...on Organization").alias(alias).projection(subProjection));
+ add$(new GraphQLResponseField("...on Organization").alias(alias).projection(subProjection));
return this;
}
@@ -36,7 +46,7 @@ public UpdateNodeUnionResponseProjection typename() {
}
public UpdateNodeUnionResponseProjection typename(String alias) {
- fields.add(new GraphQLResponseField("__typename").alias(alias));
+ add$(new GraphQLResponseField("__typename").alias(alias));
return this;
}
@@ -47,4 +57,10 @@ public UpdateNodeUnionResponseProjection typename(String alias) {
public GraphQLResponseProjection all$(int maxDepth) {
return null;
}
+
+ @Override
+ public UpdateNodeUnionResponseProjection deepCopy$() {
+ return new UpdateNodeUnionResponseProjection(this);
+ }
+
}
diff --git a/src/test/resources/expected-classes/empty/EventResponseProjection.java.txt b/src/test/resources/expected-classes/empty/EventResponseProjection.java.txt
index 6a3b27772..ffcd71920 100644
--- a/src/test/resources/expected-classes/empty/EventResponseProjection.java.txt
+++ b/src/test/resources/expected-classes/empty/EventResponseProjection.java.txt
@@ -2,6 +2,7 @@ import com.kobylynskyi.graphql.codegen.model.graphql.GraphQLResponseField;
import com.kobylynskyi.graphql.codegen.model.graphql.GraphQLResponseProjection;
import java.util.HashMap;
import java.util.Map;
+import java.util.List;
/**
* Response projection for Event
@@ -17,6 +18,14 @@ public class EventResponseProjection extends GraphQLResponseProjection {
public EventResponseProjection() {
}
+ public EventResponseProjection(EventResponseProjection projection) {
+ super(projection);
+ }
+
+ public EventResponseProjection(List projections) {
+ super(projections);
+ }
+
public EventResponseProjection all$() {
return all$(3);
}
@@ -31,9 +40,14 @@ public class EventResponseProjection extends GraphQLResponseProjection {
}
public EventResponseProjection typename(String alias) {
- fields.add(new GraphQLResponseField("__typename").alias(alias));
+ add$(new GraphQLResponseField("__typename").alias(alias));
return this;
}
+ @Override
+ public EventResponseProjection deepCopy$() {
+ return new EventResponseProjection(this);
+ }
+
-}
+}
\ No newline at end of file
diff --git a/src/test/resources/expected-classes/extend/request/AssetResponseProjection.java.txt b/src/test/resources/expected-classes/extend/request/AssetResponseProjection.java.txt
index a6a8bb3b2..f4d26b019 100644
--- a/src/test/resources/expected-classes/extend/request/AssetResponseProjection.java.txt
+++ b/src/test/resources/expected-classes/extend/request/AssetResponseProjection.java.txt
@@ -2,6 +2,7 @@ import com.kobylynskyi.graphql.codegen.model.graphql.GraphQLResponseField;
import com.kobylynskyi.graphql.codegen.model.graphql.GraphQLResponseProjection;
import java.util.HashMap;
import java.util.Map;
+import java.util.List;
/**
* Response projection for Asset
@@ -17,6 +18,14 @@ public class AssetResponseProjection extends GraphQLResponseProjection {
public AssetResponseProjection() {
}
+ public AssetResponseProjection(AssetResponseProjection projection) {
+ super(projection);
+ }
+
+ public AssetResponseProjection(List projections) {
+ super(projections);
+ }
+
public AssetResponseProjection all$() {
return all$(3);
}
@@ -35,7 +44,7 @@ public class AssetResponseProjection extends GraphQLResponseProjection {
}
public AssetResponseProjection name(String alias) {
- fields.add(new GraphQLResponseField("name").alias(alias));
+ add$(new GraphQLResponseField("name").alias(alias));
return this;
}
@@ -44,7 +53,7 @@ public class AssetResponseProjection extends GraphQLResponseProjection {
}
public AssetResponseProjection status(String alias) {
- fields.add(new GraphQLResponseField("status").alias(alias));
+ add$(new GraphQLResponseField("status").alias(alias));
return this;
}
@@ -53,7 +62,7 @@ public class AssetResponseProjection extends GraphQLResponseProjection {
}
public AssetResponseProjection id(String alias) {
- fields.add(new GraphQLResponseField("id").alias(alias));
+ add$(new GraphQLResponseField("id").alias(alias));
return this;
}
@@ -62,7 +71,7 @@ public class AssetResponseProjection extends GraphQLResponseProjection {
}
public AssetResponseProjection createdBy(String alias) {
- fields.add(new GraphQLResponseField("createdBy").alias(alias));
+ add$(new GraphQLResponseField("createdBy").alias(alias));
return this;
}
@@ -71,9 +80,14 @@ public class AssetResponseProjection extends GraphQLResponseProjection {
}
public AssetResponseProjection typename(String alias) {
- fields.add(new GraphQLResponseField("__typename").alias(alias));
+ add$(new GraphQLResponseField("__typename").alias(alias));
return this;
}
+ @Override
+ public AssetResponseProjection deepCopy$() {
+ return new AssetResponseProjection(this);
+ }
+
-}
+}
\ No newline at end of file
diff --git a/src/test/resources/expected-classes/extend/request/EventResponseProjection.java.txt b/src/test/resources/expected-classes/extend/request/EventResponseProjection.java.txt
index ee75de8c3..e2a104929 100644
--- a/src/test/resources/expected-classes/extend/request/EventResponseProjection.java.txt
+++ b/src/test/resources/expected-classes/extend/request/EventResponseProjection.java.txt
@@ -2,6 +2,7 @@ import com.kobylynskyi.graphql.codegen.model.graphql.GraphQLResponseField;
import com.kobylynskyi.graphql.codegen.model.graphql.GraphQLResponseProjection;
import java.util.HashMap;
import java.util.Map;
+import java.util.List;
/**
* Response projection for Event
@@ -17,6 +18,14 @@ public class EventResponseProjection extends GraphQLResponseProjection {
public EventResponseProjection() {
}
+ public EventResponseProjection(EventResponseProjection projection) {
+ super(projection);
+ }
+
+ public EventResponseProjection(List projections) {
+ super(projections);
+ }
+
public EventResponseProjection all$() {
return all$(3);
}
@@ -39,7 +48,7 @@ public class EventResponseProjection extends GraphQLResponseProjection {
}
public EventResponseProjection status(String alias) {
- fields.add(new GraphQLResponseField("status").alias(alias));
+ add$(new GraphQLResponseField("status").alias(alias));
return this;
}
@@ -48,7 +57,7 @@ public class EventResponseProjection extends GraphQLResponseProjection {
}
public EventResponseProjection createdDateTime(String alias) {
- fields.add(new GraphQLResponseField("createdDateTime").alias(alias));
+ add$(new GraphQLResponseField("createdDateTime").alias(alias));
return this;
}
@@ -57,7 +66,7 @@ public class EventResponseProjection extends GraphQLResponseProjection {
}
public EventResponseProjection assets(String alias, AssetResponseProjection subProjection) {
- fields.add(new GraphQLResponseField("assets").alias(alias).projection(subProjection));
+ add$(new GraphQLResponseField("assets").alias(alias).projection(subProjection));
return this;
}
@@ -66,7 +75,7 @@ public class EventResponseProjection extends GraphQLResponseProjection {
}
public EventResponseProjection id(String alias) {
- fields.add(new GraphQLResponseField("id").alias(alias));
+ add$(new GraphQLResponseField("id").alias(alias));
return this;
}
@@ -75,7 +84,7 @@ public class EventResponseProjection extends GraphQLResponseProjection {
}
public EventResponseProjection createdBy(String alias) {
- fields.add(new GraphQLResponseField("createdBy").alias(alias));
+ add$(new GraphQLResponseField("createdBy").alias(alias));
return this;
}
@@ -84,9 +93,14 @@ public class EventResponseProjection extends GraphQLResponseProjection {
}
public EventResponseProjection typename(String alias) {
- fields.add(new GraphQLResponseField("__typename").alias(alias));
+ add$(new GraphQLResponseField("__typename").alias(alias));
return this;
}
+ @Override
+ public EventResponseProjection deepCopy$() {
+ return new EventResponseProjection(this);
+ }
+
-}
+}
\ No newline at end of file
diff --git a/src/test/resources/expected-classes/from-introspection-result/ProductResponseProjection.java.txt b/src/test/resources/expected-classes/from-introspection-result/ProductResponseProjection.java.txt
index 35a0a4b1c..e8f81f34c 100644
--- a/src/test/resources/expected-classes/from-introspection-result/ProductResponseProjection.java.txt
+++ b/src/test/resources/expected-classes/from-introspection-result/ProductResponseProjection.java.txt
@@ -4,6 +4,7 @@ import com.kobylynskyi.graphql.codegen.model.graphql.GraphQLResponseField;
import com.kobylynskyi.graphql.codegen.model.graphql.GraphQLResponseProjection;
import java.util.HashMap;
import java.util.Map;
+import java.util.List;
/**
* Response projection for Product
@@ -19,6 +20,14 @@ public class ProductResponseProjection extends GraphQLResponseProjection {
public ProductResponseProjection() {
}
+ public ProductResponseProjection(ProductResponseProjection projection) {
+ super(projection);
+ }
+
+ public ProductResponseProjection(List projections) {
+ super(projections);
+ }
+
public ProductResponseProjection all$() {
return all$(3);
}
@@ -40,7 +49,7 @@ public class ProductResponseProjection extends GraphQLResponseProjection {
}
public ProductResponseProjection id(String alias) {
- fields.add(new GraphQLResponseField("id").alias(alias));
+ add$(new GraphQLResponseField("id").alias(alias));
return this;
}
@@ -49,7 +58,7 @@ public class ProductResponseProjection extends GraphQLResponseProjection {
}
public ProductResponseProjection title(String alias) {
- fields.add(new GraphQLResponseField("title").alias(alias));
+ add$(new GraphQLResponseField("title").alias(alias));
return this;
}
@@ -58,7 +67,7 @@ public class ProductResponseProjection extends GraphQLResponseProjection {
}
public ProductResponseProjection description(String alias) {
- fields.add(new GraphQLResponseField("description").alias(alias));
+ add$(new GraphQLResponseField("description").alias(alias));
return this;
}
@@ -67,7 +76,7 @@ public class ProductResponseProjection extends GraphQLResponseProjection {
}
public ProductResponseProjection price(String alias) {
- fields.add(new GraphQLResponseField("price").alias(alias));
+ add$(new GraphQLResponseField("price").alias(alias));
return this;
}
@@ -76,7 +85,7 @@ public class ProductResponseProjection extends GraphQLResponseProjection {
}
public ProductResponseProjection sku(String alias) {
- fields.add(new GraphQLResponseField("sku").alias(alias));
+ add$(new GraphQLResponseField("sku").alias(alias));
return this;
}
@@ -85,7 +94,7 @@ public class ProductResponseProjection extends GraphQLResponseProjection {
}
public ProductResponseProjection stockStatus(String alias) {
- fields.add(new GraphQLResponseField("stockStatus").alias(alias));
+ add$(new GraphQLResponseField("stockStatus").alias(alias));
return this;
}
@@ -94,7 +103,7 @@ public class ProductResponseProjection extends GraphQLResponseProjection {
}
public ProductResponseProjection addedDateTime(String alias) {
- fields.add(new GraphQLResponseField("addedDateTime").alias(alias));
+ add$(new GraphQLResponseField("addedDateTime").alias(alias));
return this;
}
@@ -103,9 +112,14 @@ public class ProductResponseProjection extends GraphQLResponseProjection {
}
public ProductResponseProjection typename(String alias) {
- fields.add(new GraphQLResponseField("__typename").alias(alias));
+ add$(new GraphQLResponseField("__typename").alias(alias));
return this;
}
+ @Override
+ public ProductResponseProjection deepCopy$() {
+ return new ProductResponseProjection(this);
+ }
+
-}
+}
\ No newline at end of file
diff --git a/src/test/resources/expected-classes/kt/SearchResultItemConnectionResponseProjection.kt.txt b/src/test/resources/expected-classes/kt/SearchResultItemConnectionResponseProjection.kt.txt
index b21735ecc..cdaf038e7 100644
--- a/src/test/resources/expected-classes/kt/SearchResultItemConnectionResponseProjection.kt.txt
+++ b/src/test/resources/expected-classes/kt/SearchResultItemConnectionResponseProjection.kt.txt
@@ -11,7 +11,13 @@ import java.util.Objects
value = ["com.kobylynskyi.graphql.codegen.GraphQLCodegen"],
date = "2020-12-31T23:59:59-0500"
)
-open class SearchResultItemConnectionResponseProjection : GraphQLResponseProjection() {
+open class SearchResultItemConnectionResponseProjection : GraphQLResponseProjection {
+
+ constructor(): super()
+
+ constructor(projection: SearchResultItemConnectionResponseProjection): super(projection)
+
+ constructor(projections: List): super(projections)
private val projectionDepthOnFields: MutableMap by lazy { mutableMapOf() }
@@ -42,66 +48,68 @@ open class SearchResultItemConnectionResponseProjection : GraphQLResponseProject
fun codeCount(): SearchResultItemConnectionResponseProjection = codeCount(null)
fun codeCount(alias: String?): SearchResultItemConnectionResponseProjection {
- fields.add(GraphQLResponseField("codeCount").alias(alias))
+ `add$`(GraphQLResponseField("codeCount").alias(alias))
return this
}
fun edges(subProjection: SearchResultItemEdgeResponseProjection): SearchResultItemConnectionResponseProjection = edges(null, subProjection)
fun edges(alias: String?, subProjection: SearchResultItemEdgeResponseProjection): SearchResultItemConnectionResponseProjection {
- fields.add(GraphQLResponseField("edges").alias(alias).projection(subProjection))
+ `add$`(GraphQLResponseField("edges").alias(alias).projection(subProjection))
return this
}
fun issueCount(): SearchResultItemConnectionResponseProjection = issueCount(null)
fun issueCount(alias: String?): SearchResultItemConnectionResponseProjection {
- fields.add(GraphQLResponseField("issueCount").alias(alias))
+ `add$`(GraphQLResponseField("issueCount").alias(alias))
return this
}
fun nodes(subProjection: SearchResultItemResponseProjection): SearchResultItemConnectionResponseProjection = nodes(null, subProjection)
fun nodes(alias: String?, subProjection: SearchResultItemResponseProjection): SearchResultItemConnectionResponseProjection {
- fields.add(GraphQLResponseField("nodes").alias(alias).projection(subProjection))
+ `add$`(GraphQLResponseField("nodes").alias(alias).projection(subProjection))
return this
}
fun pageInfo(subProjection: PageInfoResponseProjection): SearchResultItemConnectionResponseProjection = pageInfo(null, subProjection)
fun pageInfo(alias: String?, subProjection: PageInfoResponseProjection): SearchResultItemConnectionResponseProjection {
- fields.add(GraphQLResponseField("pageInfo").alias(alias).projection(subProjection))
+ `add$`(GraphQLResponseField("pageInfo").alias(alias).projection(subProjection))
return this
}
fun repositoryCount(): SearchResultItemConnectionResponseProjection = repositoryCount(null)
fun repositoryCount(alias: String?): SearchResultItemConnectionResponseProjection {
- fields.add(GraphQLResponseField("repositoryCount").alias(alias))
+ `add$`(GraphQLResponseField("repositoryCount").alias(alias))
return this
}
fun userCount(): SearchResultItemConnectionResponseProjection = userCount(null)
fun userCount(alias: String?): SearchResultItemConnectionResponseProjection {
- fields.add(GraphQLResponseField("userCount").alias(alias))
+ `add$`(GraphQLResponseField("userCount").alias(alias))
return this
}
fun wikiCount(): SearchResultItemConnectionResponseProjection = wikiCount(null)
fun wikiCount(alias: String?): SearchResultItemConnectionResponseProjection {
- fields.add(GraphQLResponseField("wikiCount").alias(alias))
+ `add$`(GraphQLResponseField("wikiCount").alias(alias))
return this
}
fun typename(): SearchResultItemConnectionResponseProjection = typename(null)
fun typename(alias: String?): SearchResultItemConnectionResponseProjection {
- fields.add(GraphQLResponseField("__typename").alias(alias))
+ `add$`(GraphQLResponseField("__typename").alias(alias))
return this
}
+ override fun `deepCopy$`(): SearchResultItemConnectionResponseProjection = SearchResultItemConnectionResponseProjection(this)
+
override fun equals(other: Any?): Boolean {
if (this === other) {
return true
@@ -115,4 +123,4 @@ open class SearchResultItemConnectionResponseProjection : GraphQLResponseProject
override fun hashCode(): Int = Objects.hash(fields)
-}
+}
\ No newline at end of file
diff --git a/src/test/resources/expected-classes/kt/SearchResultItemResponseProjection.kt.txt b/src/test/resources/expected-classes/kt/SearchResultItemResponseProjection.kt.txt
index 615a7f878..4585bafe1 100644
--- a/src/test/resources/expected-classes/kt/SearchResultItemResponseProjection.kt.txt
+++ b/src/test/resources/expected-classes/kt/SearchResultItemResponseProjection.kt.txt
@@ -11,7 +11,13 @@ import java.util.Objects
value = ["com.kobylynskyi.graphql.codegen.GraphQLCodegen"],
date = "2020-12-31T23:59:59-0500"
)
-open class SearchResultItemResponseProjection : GraphQLResponseProjection() {
+open class SearchResultItemResponseProjection : GraphQLResponseProjection {
+
+ constructor(): super()
+
+ constructor(projection: SearchResultItemResponseProjection): super(projection)
+
+ constructor(projections: List): super(projections)
private val projectionDepthOnFields: MutableMap by lazy { mutableMapOf() }
@@ -25,59 +31,61 @@ open class SearchResultItemResponseProjection : GraphQLResponseProjection() {
fun onApp(subProjection: AppResponseProjection): SearchResultItemResponseProjection = onApp(null, subProjection)
fun onApp(alias: String?, subProjection: AppResponseProjection): SearchResultItemResponseProjection {
- fields.add(GraphQLResponseField("...on App").alias(alias).projection(subProjection))
+ `add$`(GraphQLResponseField("...on App").alias(alias).projection(subProjection))
return this
}
fun onRepository(subProjection: RepositoryResponseProjection): SearchResultItemResponseProjection = onRepository(null, subProjection)
fun onRepository(alias: String?, subProjection: RepositoryResponseProjection): SearchResultItemResponseProjection {
- fields.add(GraphQLResponseField("...on Repository").alias(alias).projection(subProjection))
+ `add$`(GraphQLResponseField("...on Repository").alias(alias).projection(subProjection))
return this
}
fun onIssue(subProjection: IssueResponseProjection): SearchResultItemResponseProjection = onIssue(null, subProjection)
fun onIssue(alias: String?, subProjection: IssueResponseProjection): SearchResultItemResponseProjection {
- fields.add(GraphQLResponseField("...on Issue").alias(alias).projection(subProjection))
+ `add$`(GraphQLResponseField("...on Issue").alias(alias).projection(subProjection))
return this
}
fun onOrganization(subProjection: OrganizationResponseProjection): SearchResultItemResponseProjection = onOrganization(null, subProjection)
fun onOrganization(alias: String?, subProjection: OrganizationResponseProjection): SearchResultItemResponseProjection {
- fields.add(GraphQLResponseField("...on Organization").alias(alias).projection(subProjection))
+ `add$`(GraphQLResponseField("...on Organization").alias(alias).projection(subProjection))
return this
}
fun onUser(subProjection: UserResponseProjection): SearchResultItemResponseProjection = onUser(null, subProjection)
fun onUser(alias: String?, subProjection: UserResponseProjection): SearchResultItemResponseProjection {
- fields.add(GraphQLResponseField("...on User").alias(alias).projection(subProjection))
+ `add$`(GraphQLResponseField("...on User").alias(alias).projection(subProjection))
return this
}
fun onMarketplaceListing(subProjection: MarketplaceListingResponseProjection): SearchResultItemResponseProjection = onMarketplaceListing(null, subProjection)
fun onMarketplaceListing(alias: String?, subProjection: MarketplaceListingResponseProjection): SearchResultItemResponseProjection {
- fields.add(GraphQLResponseField("...on MarketplaceListing").alias(alias).projection(subProjection))
+ `add$`(GraphQLResponseField("...on MarketplaceListing").alias(alias).projection(subProjection))
return this
}
fun onPullRequest(subProjection: PullRequestResponseProjection): SearchResultItemResponseProjection = onPullRequest(null, subProjection)
fun onPullRequest(alias: String?, subProjection: PullRequestResponseProjection): SearchResultItemResponseProjection {
- fields.add(GraphQLResponseField("...on PullRequest").alias(alias).projection(subProjection))
+ `add$`(GraphQLResponseField("...on PullRequest").alias(alias).projection(subProjection))
return this
}
fun typename(): SearchResultItemResponseProjection = typename(null)
fun typename(alias: String?): SearchResultItemResponseProjection {
- fields.add(GraphQLResponseField("__typename").alias(alias))
+ `add$`(GraphQLResponseField("__typename").alias(alias))
return this
}
+ override fun `deepCopy$`(): SearchResultItemResponseProjection = SearchResultItemResponseProjection(this)
+
override fun equals(other: Any?): Boolean {
if (this === other) {
return true
@@ -91,4 +99,4 @@ open class SearchResultItemResponseProjection : GraphQLResponseProjection() {
override fun hashCode(): Int = Objects.hash(fields)
-}
+}
\ No newline at end of file
diff --git a/src/test/resources/expected-classes/kt/empty/EventResponseProjection.kt.txt b/src/test/resources/expected-classes/kt/empty/EventResponseProjection.kt.txt
index 75c42178b..f60516975 100644
--- a/src/test/resources/expected-classes/kt/empty/EventResponseProjection.kt.txt
+++ b/src/test/resources/expected-classes/kt/empty/EventResponseProjection.kt.txt
@@ -8,7 +8,13 @@ import com.kobylynskyi.graphql.codegen.model.graphql.GraphQLResponseProjection
value = ["com.kobylynskyi.graphql.codegen.GraphQLCodegen"],
date = "2020-12-31T23:59:59-0500"
)
-open class EventResponseProjection : GraphQLResponseProjection() {
+open class EventResponseProjection : GraphQLResponseProjection {
+
+ constructor(): super()
+
+ constructor(projection: EventResponseProjection): super(projection)
+
+ constructor(projections: List): super(projections)
private val projectionDepthOnFields: MutableMap by lazy { mutableMapOf() }
@@ -22,9 +28,11 @@ open class EventResponseProjection : GraphQLResponseProjection() {
fun typename(): EventResponseProjection = typename(null)
fun typename(alias: String?): EventResponseProjection {
- fields.add(GraphQLResponseField("__typename").alias(alias))
+ `add$`(GraphQLResponseField("__typename").alias(alias))
return this
}
+ override fun `deepCopy$`(): EventResponseProjection = EventResponseProjection(this)
+
-}
+}
\ No newline at end of file
diff --git a/src/test/resources/expected-classes/kt/restricted-words/CharResponseProjection.kt.txt b/src/test/resources/expected-classes/kt/restricted-words/CharResponseProjection.kt.txt
index 42d33e7fe..73519c1a3 100644
--- a/src/test/resources/expected-classes/kt/restricted-words/CharResponseProjection.kt.txt
+++ b/src/test/resources/expected-classes/kt/restricted-words/CharResponseProjection.kt.txt
@@ -11,7 +11,13 @@ import java.util.Objects
value = ["com.kobylynskyi.graphql.codegen.GraphQLCodegen"],
date = "2020-12-31T23:59:59-0500"
)
-open class CharResponseProjection : GraphQLResponseProjection() {
+open class CharResponseProjection : GraphQLResponseProjection {
+
+ constructor(): super()
+
+ constructor(projection: CharResponseProjection): super(projection)
+
+ constructor(projections: List): super(projections)
private val projectionDepthOnFields: MutableMap by lazy { mutableMapOf() }
@@ -25,10 +31,12 @@ open class CharResponseProjection : GraphQLResponseProjection() {
fun typename(): CharResponseProjection = typename(null)
fun typename(alias: String?): CharResponseProjection {
- fields.add(GraphQLResponseField("__typename").alias(alias))
+ `add$`(GraphQLResponseField("__typename").alias(alias))
return this
}
+ override fun `deepCopy$`(): CharResponseProjection = CharResponseProjection(this)
+
override fun equals(other: Any?): Boolean {
if (this === other) {
return true
@@ -42,4 +50,4 @@ open class CharResponseProjection : GraphQLResponseProjection() {
override fun hashCode(): Int = Objects.hash(fields)
-}
+}
\ No newline at end of file
diff --git a/src/test/resources/expected-classes/kt/restricted-words/QueryFunParametrizedInput.kt.txt b/src/test/resources/expected-classes/kt/restricted-words/QueryFunParametrizedInput.kt.txt
index 1ff7dae2f..44fa206e5 100644
--- a/src/test/resources/expected-classes/kt/restricted-words/QueryFunParametrizedInput.kt.txt
+++ b/src/test/resources/expected-classes/kt/restricted-words/QueryFunParametrizedInput.kt.txt
@@ -14,6 +14,13 @@ data class QueryFunParametrizedInput(
val final: Int?
) : GraphQLParametrizedInput {
+ override fun deepCopy(): QueryFunParametrizedInput {
+ return QueryFunParametrizedInput(
+ this.final
+ )
+
+ }
+
override fun toString(): String {
val joiner = StringJoiner(", ", "( ", " )")
if (final != null) {
diff --git a/src/test/resources/expected-classes/kt/restricted-words/QueryPrivateParametrizedInput.kt.txt b/src/test/resources/expected-classes/kt/restricted-words/QueryPrivateParametrizedInput.kt.txt
index 63367fbb4..70abf58d6 100644
--- a/src/test/resources/expected-classes/kt/restricted-words/QueryPrivateParametrizedInput.kt.txt
+++ b/src/test/resources/expected-classes/kt/restricted-words/QueryPrivateParametrizedInput.kt.txt
@@ -17,6 +17,16 @@ data class QueryPrivateParametrizedInput(
val createdAfter: java.time.ZonedDateTime?
) : GraphQLParametrizedInput {
+ override fun deepCopy(): QueryPrivateParametrizedInput {
+ return QueryPrivateParametrizedInput(
+ this.int,
+ this.new,
+ this.enum,
+ this.createdAfter
+ )
+
+ }
+
override fun toString(): String {
val joiner = StringJoiner(", ", "( ", " )")
if (int != null) {
diff --git a/src/test/resources/expected-classes/projection-with-selectAll/LocationResponseProjection.java.txt b/src/test/resources/expected-classes/projection-with-selectAll/LocationResponseProjection.java.txt
index 09147b077..0a31b1522 100644
--- a/src/test/resources/expected-classes/projection-with-selectAll/LocationResponseProjection.java.txt
+++ b/src/test/resources/expected-classes/projection-with-selectAll/LocationResponseProjection.java.txt
@@ -4,6 +4,7 @@ import com.kobylynskyi.graphql.codegen.model.graphql.GraphQLResponseField;
import com.kobylynskyi.graphql.codegen.model.graphql.GraphQLResponseProjection;
import java.util.HashMap;
import java.util.Map;
+import java.util.List;
/**
* Response projection for Location
@@ -19,6 +20,14 @@ public class LocationResponseProjection extends GraphQLResponseProjection {
public LocationResponseProjection() {
}
+ public LocationResponseProjection(LocationResponseProjection projection) {
+ super(projection);
+ }
+
+ public LocationResponseProjection(List projections) {
+ super(projections);
+ }
+
public LocationResponseProjection all$() {
return all$(3);
}
@@ -35,7 +44,7 @@ public class LocationResponseProjection extends GraphQLResponseProjection {
}
public LocationResponseProjection id(String alias) {
- fields.add(new GraphQLResponseField("id").alias(alias));
+ add$(new GraphQLResponseField("id").alias(alias));
return this;
}
@@ -44,7 +53,7 @@ public class LocationResponseProjection extends GraphQLResponseProjection {
}
public LocationResponseProjection locationType(String alias) {
- fields.add(new GraphQLResponseField("locationType").alias(alias));
+ add$(new GraphQLResponseField("locationType").alias(alias));
return this;
}
@@ -53,7 +62,7 @@ public class LocationResponseProjection extends GraphQLResponseProjection {
}
public LocationResponseProjection onCustomerLocation(String alias, CustomerLocationResponseProjection subProjection) {
- fields.add(new GraphQLResponseField("...on CustomerLocation").alias(alias).projection(subProjection));
+ add$(new GraphQLResponseField("...on CustomerLocation").alias(alias).projection(subProjection));
return this;
}
@@ -62,7 +71,7 @@ public class LocationResponseProjection extends GraphQLResponseProjection {
}
public LocationResponseProjection onDealerLocation(String alias, DealerLocationResponseProjection subProjection) {
- fields.add(new GraphQLResponseField("...on DealerLocation").alias(alias).projection(subProjection));
+ add$(new GraphQLResponseField("...on DealerLocation").alias(alias).projection(subProjection));
return this;
}
@@ -71,9 +80,14 @@ public class LocationResponseProjection extends GraphQLResponseProjection {
}
public LocationResponseProjection typename(String alias) {
- fields.add(new GraphQLResponseField("__typename").alias(alias));
+ add$(new GraphQLResponseField("__typename").alias(alias));
return this;
}
+ @Override
+ public LocationResponseProjection deepCopy$() {
+ return new LocationResponseProjection(this);
+ }
+
-}
+}
\ No newline at end of file
diff --git a/src/test/resources/expected-classes/projection-with-selectAll/VehicleResponseProjection.java.txt b/src/test/resources/expected-classes/projection-with-selectAll/VehicleResponseProjection.java.txt
index b8027a9f8..40831cca3 100644
--- a/src/test/resources/expected-classes/projection-with-selectAll/VehicleResponseProjection.java.txt
+++ b/src/test/resources/expected-classes/projection-with-selectAll/VehicleResponseProjection.java.txt
@@ -4,6 +4,7 @@ import com.kobylynskyi.graphql.codegen.model.graphql.GraphQLResponseField;
import com.kobylynskyi.graphql.codegen.model.graphql.GraphQLResponseProjection;
import java.util.HashMap;
import java.util.Map;
+import java.util.List;
/**
* Response projection for Vehicle
@@ -19,6 +20,14 @@ public class VehicleResponseProjection extends GraphQLResponseProjection {
public VehicleResponseProjection() {
}
+ public VehicleResponseProjection(VehicleResponseProjection projection) {
+ super(projection);
+ }
+
+ public VehicleResponseProjection(List projections) {
+ super(projections);
+ }
+
public VehicleResponseProjection all$() {
return all$(3);
}
@@ -39,7 +48,7 @@ public class VehicleResponseProjection extends GraphQLResponseProjection {
}
public VehicleResponseProjection vehicleId(String alias) {
- fields.add(new GraphQLResponseField("vehicleId").alias(alias));
+ add$(new GraphQLResponseField("vehicleId").alias(alias));
return this;
}
@@ -48,7 +57,7 @@ public class VehicleResponseProjection extends GraphQLResponseProjection {
}
public VehicleResponseProjection registrationNumber(String alias) {
- fields.add(new GraphQLResponseField("registrationNumber").alias(alias));
+ add$(new GraphQLResponseField("registrationNumber").alias(alias));
return this;
}
@@ -57,7 +66,7 @@ public class VehicleResponseProjection extends GraphQLResponseProjection {
}
public VehicleResponseProjection location(String alias, LocationResponseProjection subProjection) {
- fields.add(new GraphQLResponseField("location").alias(alias).projection(subProjection));
+ add$(new GraphQLResponseField("location").alias(alias).projection(subProjection));
return this;
}
@@ -66,9 +75,14 @@ public class VehicleResponseProjection extends GraphQLResponseProjection {
}
public VehicleResponseProjection typename(String alias) {
- fields.add(new GraphQLResponseField("__typename").alias(alias));
+ add$(new GraphQLResponseField("__typename").alias(alias));
return this;
}
+ @Override
+ public VehicleResponseProjection deepCopy$() {
+ return new VehicleResponseProjection(this);
+ }
+
-}
+}
\ No newline at end of file
diff --git a/src/test/resources/expected-classes/request/ClientDataParametrizedInput.java.txt b/src/test/resources/expected-classes/request/ClientDataParametrizedInput.java.txt
index 3bc9a2b8e..3f57ec7b4 100644
--- a/src/test/resources/expected-classes/request/ClientDataParametrizedInput.java.txt
+++ b/src/test/resources/expected-classes/request/ClientDataParametrizedInput.java.txt
@@ -28,6 +28,13 @@ public class ClientDataParametrizedInput implements GraphQLParametrizedInput {
return this;
}
+ @Override
+ public ClientDataParametrizedInput deepCopy() {
+ ClientDataParametrizedInput parametrizedInput = new ClientDataParametrizedInput();
+ parametrizedInput.ID(this.ID);
+ return parametrizedInput;
+ }
+
@Override
public boolean equals(Object obj) {
if (this == obj) {
@@ -52,4 +59,4 @@ public class ClientDataParametrizedInput implements GraphQLParametrizedInput {
return joiner.toString();
}
-}
+}
\ No newline at end of file
diff --git a/src/test/resources/expected-classes/request/CodeOfConductResponseProjection.java.txt b/src/test/resources/expected-classes/request/CodeOfConductResponseProjection.java.txt
index dd838e951..f82517af5 100644
--- a/src/test/resources/expected-classes/request/CodeOfConductResponseProjection.java.txt
+++ b/src/test/resources/expected-classes/request/CodeOfConductResponseProjection.java.txt
@@ -4,6 +4,7 @@ import com.kobylynskyi.graphql.codegen.model.graphql.GraphQLResponseField;
import com.kobylynskyi.graphql.codegen.model.graphql.GraphQLResponseProjection;
import java.util.HashMap;
import java.util.Map;
+import java.util.List;
import java.util.Objects;
/**
@@ -20,6 +21,14 @@ public class CodeOfConductResponseProjection extends GraphQLResponseProjection {
public CodeOfConductResponseProjection() {
}
+ public CodeOfConductResponseProjection(CodeOfConductResponseProjection projection) {
+ super(projection);
+ }
+
+ public CodeOfConductResponseProjection(List projections) {
+ super(projections);
+ }
+
public CodeOfConductResponseProjection all$() {
return all$(3);
}
@@ -40,7 +49,7 @@ public class CodeOfConductResponseProjection extends GraphQLResponseProjection {
}
public CodeOfConductResponseProjection body(String alias) {
- fields.add(new GraphQLResponseField("body").alias(alias));
+ add$(new GraphQLResponseField("body").alias(alias));
return this;
}
@@ -49,7 +58,7 @@ public class CodeOfConductResponseProjection extends GraphQLResponseProjection {
}
public CodeOfConductResponseProjection id(String alias) {
- fields.add(new GraphQLResponseField("id").alias(alias));
+ add$(new GraphQLResponseField("id").alias(alias));
return this;
}
@@ -58,7 +67,7 @@ public class CodeOfConductResponseProjection extends GraphQLResponseProjection {
}
public CodeOfConductResponseProjection key(String alias) {
- fields.add(new GraphQLResponseField("key").alias(alias));
+ add$(new GraphQLResponseField("key").alias(alias));
return this;
}
@@ -67,7 +76,7 @@ public class CodeOfConductResponseProjection extends GraphQLResponseProjection {
}
public CodeOfConductResponseProjection name(String alias) {
- fields.add(new GraphQLResponseField("name").alias(alias));
+ add$(new GraphQLResponseField("name").alias(alias));
return this;
}
@@ -76,7 +85,7 @@ public class CodeOfConductResponseProjection extends GraphQLResponseProjection {
}
public CodeOfConductResponseProjection resourcePath(String alias) {
- fields.add(new GraphQLResponseField("resourcePath").alias(alias));
+ add$(new GraphQLResponseField("resourcePath").alias(alias));
return this;
}
@@ -85,7 +94,7 @@ public class CodeOfConductResponseProjection extends GraphQLResponseProjection {
}
public CodeOfConductResponseProjection url(String alias) {
- fields.add(new GraphQLResponseField("url").alias(alias));
+ add$(new GraphQLResponseField("url").alias(alias));
return this;
}
@@ -94,10 +103,15 @@ public class CodeOfConductResponseProjection extends GraphQLResponseProjection {
}
public CodeOfConductResponseProjection typename(String alias) {
- fields.add(new GraphQLResponseField("__typename").alias(alias));
+ add$(new GraphQLResponseField("__typename").alias(alias));
return this;
}
+ @Override
+ public CodeOfConductResponseProjection deepCopy$() {
+ return new CodeOfConductResponseProjection(this);
+ }
+
@Override
public boolean equals(Object obj) {
if (this == obj) {
@@ -115,4 +129,4 @@ public class CodeOfConductResponseProjection extends GraphQLResponseProjection {
return Objects.hash(fields);
}
-}
+}
\ No newline at end of file
diff --git a/src/test/resources/expected-classes/request/EventPropertyChildParametrizedInput.java.txt b/src/test/resources/expected-classes/request/EventPropertyChildParametrizedInput.java.txt
index 428f0fbc7..269788aef 100644
--- a/src/test/resources/expected-classes/request/EventPropertyChildParametrizedInput.java.txt
+++ b/src/test/resources/expected-classes/request/EventPropertyChildParametrizedInput.java.txt
@@ -35,6 +35,14 @@ public class EventPropertyChildParametrizedInput implements GraphQLParametrizedI
return this;
}
+ @Override
+ public EventPropertyChildParametrizedInput deepCopy() {
+ EventPropertyChildParametrizedInput parametrizedInput = new EventPropertyChildParametrizedInput();
+ parametrizedInput.first(this.first);
+ parametrizedInput.last(this.last);
+ return parametrizedInput;
+ }
+
@Override
public boolean equals(Object obj) {
if (this == obj) {
diff --git a/src/test/resources/expected-classes/request/EventPropertyChildParametrizedInput_withoutPrimitives.java.txt b/src/test/resources/expected-classes/request/EventPropertyChildParametrizedInput_withoutPrimitives.java.txt
index 428f0fbc7..269788aef 100644
--- a/src/test/resources/expected-classes/request/EventPropertyChildParametrizedInput_withoutPrimitives.java.txt
+++ b/src/test/resources/expected-classes/request/EventPropertyChildParametrizedInput_withoutPrimitives.java.txt
@@ -35,6 +35,14 @@ public class EventPropertyChildParametrizedInput implements GraphQLParametrizedI
return this;
}
+ @Override
+ public EventPropertyChildParametrizedInput deepCopy() {
+ EventPropertyChildParametrizedInput parametrizedInput = new EventPropertyChildParametrizedInput();
+ parametrizedInput.first(this.first);
+ parametrizedInput.last(this.last);
+ return parametrizedInput;
+ }
+
@Override
public boolean equals(Object obj) {
if (this == obj) {
diff --git a/src/test/resources/expected-classes/request/EventPropertyParentParametrizedInput.java.txt b/src/test/resources/expected-classes/request/EventPropertyParentParametrizedInput.java.txt
index aa04aac82..0de644fae 100644
--- a/src/test/resources/expected-classes/request/EventPropertyParentParametrizedInput.java.txt
+++ b/src/test/resources/expected-classes/request/EventPropertyParentParametrizedInput.java.txt
@@ -35,6 +35,14 @@ public class EventPropertyParentParametrizedInput implements GraphQLParametrized
return this;
}
+ @Override
+ public EventPropertyParentParametrizedInput deepCopy() {
+ EventPropertyParentParametrizedInput parametrizedInput = new EventPropertyParentParametrizedInput();
+ parametrizedInput.withStatus(this.withStatus);
+ parametrizedInput.createdAfter(this.createdAfter);
+ return parametrizedInput;
+ }
+
@Override
public boolean equals(Object obj) {
if (this == obj) {
@@ -65,4 +73,4 @@ public class EventPropertyParentParametrizedInput implements GraphQLParametrized
return joiner.toString();
}
-}
+}
\ No newline at end of file
diff --git a/src/test/resources/expected-classes/request/EventPropertyParentParametrizedInput_withModelSuffix.java.txt b/src/test/resources/expected-classes/request/EventPropertyParentParametrizedInput_withModelSuffix.java.txt
index 9b9604ab5..2014ecffa 100644
--- a/src/test/resources/expected-classes/request/EventPropertyParentParametrizedInput_withModelSuffix.java.txt
+++ b/src/test/resources/expected-classes/request/EventPropertyParentParametrizedInput_withModelSuffix.java.txt
@@ -35,6 +35,14 @@ public class EventPropertyParentParametrizedInput implements GraphQLParametrized
return this;
}
+ @Override
+ public EventPropertyParentParametrizedInput deepCopy() {
+ EventPropertyParentParametrizedInput parametrizedInput = new EventPropertyParentParametrizedInput();
+ parametrizedInput.withStatus(this.withStatus);
+ parametrizedInput.createdAfter(this.createdAfter);
+ return parametrizedInput;
+ }
+
@Override
public boolean equals(Object obj) {
if (this == obj) {
@@ -65,4 +73,4 @@ public class EventPropertyParentParametrizedInput implements GraphQLParametrized
return joiner.toString();
}
-}
+}
\ No newline at end of file
diff --git a/src/test/resources/expected-classes/request/EventPropertyResponseProjection.java.txt b/src/test/resources/expected-classes/request/EventPropertyResponseProjection.java.txt
index 4b3f05622..0c0442ed0 100644
--- a/src/test/resources/expected-classes/request/EventPropertyResponseProjection.java.txt
+++ b/src/test/resources/expected-classes/request/EventPropertyResponseProjection.java.txt
@@ -4,6 +4,7 @@ import com.kobylynskyi.graphql.codegen.model.graphql.GraphQLResponseField;
import com.kobylynskyi.graphql.codegen.model.graphql.GraphQLResponseProjection;
import java.util.HashMap;
import java.util.Map;
+import java.util.List;
import java.util.Objects;
/**
@@ -20,6 +21,14 @@ public class EventPropertyResponseProjection extends GraphQLResponseProjection {
public EventPropertyResponseProjection() {
}
+ public EventPropertyResponseProjection(EventPropertyResponseProjection projection) {
+ super(projection);
+ }
+
+ public EventPropertyResponseProjection(List projections) {
+ super(projections);
+ }
+
public EventPropertyResponseProjection all$() {
return all$(3);
}
@@ -47,7 +56,7 @@ public class EventPropertyResponseProjection extends GraphQLResponseProjection {
}
public EventPropertyResponseProjection floatVal(String alias) {
- fields.add(new GraphQLResponseField("floatVal").alias(alias));
+ add$(new GraphQLResponseField("floatVal").alias(alias));
return this;
}
@@ -56,7 +65,7 @@ public class EventPropertyResponseProjection extends GraphQLResponseProjection {
}
public EventPropertyResponseProjection booleanVal(String alias) {
- fields.add(new GraphQLResponseField("booleanVal").alias(alias));
+ add$(new GraphQLResponseField("booleanVal").alias(alias));
return this;
}
@@ -65,7 +74,7 @@ public class EventPropertyResponseProjection extends GraphQLResponseProjection {
}
public EventPropertyResponseProjection intVal(String alias) {
- fields.add(new GraphQLResponseField("intVal").alias(alias));
+ add$(new GraphQLResponseField("intVal").alias(alias));
return this;
}
@@ -74,7 +83,7 @@ public class EventPropertyResponseProjection extends GraphQLResponseProjection {
}
public EventPropertyResponseProjection intVals(String alias) {
- fields.add(new GraphQLResponseField("intVals").alias(alias));
+ add$(new GraphQLResponseField("intVals").alias(alias));
return this;
}
@@ -83,7 +92,7 @@ public class EventPropertyResponseProjection extends GraphQLResponseProjection {
}
public EventPropertyResponseProjection stringVal(String alias) {
- fields.add(new GraphQLResponseField("stringVal").alias(alias));
+ add$(new GraphQLResponseField("stringVal").alias(alias));
return this;
}
@@ -92,7 +101,7 @@ public class EventPropertyResponseProjection extends GraphQLResponseProjection {
}
public EventPropertyResponseProjection child(String alias, EventPropertyResponseProjection subProjection) {
- fields.add(new GraphQLResponseField("child").alias(alias).projection(subProjection));
+ add$(new GraphQLResponseField("child").alias(alias).projection(subProjection));
return this;
}
@@ -101,7 +110,7 @@ public class EventPropertyResponseProjection extends GraphQLResponseProjection {
}
public EventPropertyResponseProjection child(String alias, EventPropertyChildParametrizedInput input, EventPropertyResponseProjection subProjection) {
- fields.add(new GraphQLResponseField("child").alias(alias).parameters(input).projection(subProjection));
+ add$(new GraphQLResponseField("child").alias(alias).parameters(input).projection(subProjection));
return this;
}
@@ -110,7 +119,7 @@ public class EventPropertyResponseProjection extends GraphQLResponseProjection {
}
public EventPropertyResponseProjection parent(String alias, EventResponseProjection subProjection) {
- fields.add(new GraphQLResponseField("parent").alias(alias).projection(subProjection));
+ add$(new GraphQLResponseField("parent").alias(alias).projection(subProjection));
return this;
}
@@ -119,7 +128,7 @@ public class EventPropertyResponseProjection extends GraphQLResponseProjection {
}
public EventPropertyResponseProjection parent(String alias, EventPropertyParentParametrizedInput input, EventResponseProjection subProjection) {
- fields.add(new GraphQLResponseField("parent").alias(alias).parameters(input).projection(subProjection));
+ add$(new GraphQLResponseField("parent").alias(alias).parameters(input).projection(subProjection));
return this;
}
@@ -128,10 +137,15 @@ public class EventPropertyResponseProjection extends GraphQLResponseProjection {
}
public EventPropertyResponseProjection typename(String alias) {
- fields.add(new GraphQLResponseField("__typename").alias(alias));
+ add$(new GraphQLResponseField("__typename").alias(alias));
return this;
}
+ @Override
+ public EventPropertyResponseProjection deepCopy$() {
+ return new EventPropertyResponseProjection(this);
+ }
+
@Override
public boolean equals(Object obj) {
if (this == obj) {
@@ -149,4 +163,4 @@ public class EventPropertyResponseProjection extends GraphQLResponseProjection {
return Objects.hash(fields);
}
-}
+}
\ No newline at end of file
diff --git a/src/test/resources/expected-classes/request/EventResponseProjection.java.txt b/src/test/resources/expected-classes/request/EventResponseProjection.java.txt
index 710bae7c1..d5280c7c7 100644
--- a/src/test/resources/expected-classes/request/EventResponseProjection.java.txt
+++ b/src/test/resources/expected-classes/request/EventResponseProjection.java.txt
@@ -4,6 +4,7 @@ import com.kobylynskyi.graphql.codegen.model.graphql.GraphQLResponseField;
import com.kobylynskyi.graphql.codegen.model.graphql.GraphQLResponseProjection;
import java.util.HashMap;
import java.util.Map;
+import java.util.List;
import java.util.Objects;
/**
@@ -20,6 +21,14 @@ public class EventResponseProjection extends GraphQLResponseProjection {
public EventResponseProjection() {
}
+ public EventResponseProjection(EventResponseProjection projection) {
+ super(projection);
+ }
+
+ public EventResponseProjection(List projections) {
+ super(projections);
+ }
+
public EventResponseProjection all$() {
return all$(3);
}
@@ -45,7 +54,7 @@ public class EventResponseProjection extends GraphQLResponseProjection {
}
public EventResponseProjection id(String alias) {
- fields.add(new GraphQLResponseField("id").alias(alias));
+ add$(new GraphQLResponseField("id").alias(alias));
return this;
}
@@ -54,7 +63,7 @@ public class EventResponseProjection extends GraphQLResponseProjection {
}
public EventResponseProjection categoryId(String alias) {
- fields.add(new GraphQLResponseField("categoryId").alias(alias));
+ add$(new GraphQLResponseField("categoryId").alias(alias));
return this;
}
@@ -63,7 +72,7 @@ public class EventResponseProjection extends GraphQLResponseProjection {
}
public EventResponseProjection properties(String alias, EventPropertyResponseProjection subProjection) {
- fields.add(new GraphQLResponseField("properties").alias(alias).projection(subProjection));
+ add$(new GraphQLResponseField("properties").alias(alias).projection(subProjection));
return this;
}
@@ -72,7 +81,7 @@ public class EventResponseProjection extends GraphQLResponseProjection {
}
public EventResponseProjection status(String alias) {
- fields.add(new GraphQLResponseField("status").alias(alias));
+ add$(new GraphQLResponseField("status").alias(alias));
return this;
}
@@ -81,7 +90,7 @@ public class EventResponseProjection extends GraphQLResponseProjection {
}
public EventResponseProjection createdBy(String alias) {
- fields.add(new GraphQLResponseField("createdBy").alias(alias));
+ add$(new GraphQLResponseField("createdBy").alias(alias));
return this;
}
@@ -90,7 +99,7 @@ public class EventResponseProjection extends GraphQLResponseProjection {
}
public EventResponseProjection createdDateTime(String alias) {
- fields.add(new GraphQLResponseField("createdDateTime").alias(alias));
+ add$(new GraphQLResponseField("createdDateTime").alias(alias));
return this;
}
@@ -99,7 +108,7 @@ public class EventResponseProjection extends GraphQLResponseProjection {
}
public EventResponseProjection active(String alias) {
- fields.add(new GraphQLResponseField("active").alias(alias));
+ add$(new GraphQLResponseField("active").alias(alias));
return this;
}
@@ -108,7 +117,7 @@ public class EventResponseProjection extends GraphQLResponseProjection {
}
public EventResponseProjection rating(String alias) {
- fields.add(new GraphQLResponseField("rating").alias(alias));
+ add$(new GraphQLResponseField("rating").alias(alias));
return this;
}
@@ -117,10 +126,15 @@ public class EventResponseProjection extends GraphQLResponseProjection {
}
public EventResponseProjection typename(String alias) {
- fields.add(new GraphQLResponseField("__typename").alias(alias));
+ add$(new GraphQLResponseField("__typename").alias(alias));
return this;
}
+ @Override
+ public EventResponseProjection deepCopy$() {
+ return new EventResponseProjection(this);
+ }
+
@Override
public boolean equals(Object obj) {
if (this == obj) {
@@ -138,4 +152,4 @@ public class EventResponseProjection extends GraphQLResponseProjection {
return Objects.hash(fields);
}
-}
+}
\ No newline at end of file
diff --git a/src/test/resources/expected-classes/request/EventResponseProjection.java_withoutAll.txt b/src/test/resources/expected-classes/request/EventResponseProjection.java_withoutAll.txt
index 53dcfe6fc..772d3eccc 100644
--- a/src/test/resources/expected-classes/request/EventResponseProjection.java_withoutAll.txt
+++ b/src/test/resources/expected-classes/request/EventResponseProjection.java_withoutAll.txt
@@ -2,6 +2,7 @@ package com.github.graphql;
import com.kobylynskyi.graphql.codegen.model.graphql.GraphQLResponseField;
import com.kobylynskyi.graphql.codegen.model.graphql.GraphQLResponseProjection;
+import java.util.List;
import java.util.Objects;
/**
@@ -16,12 +17,20 @@ public class EventResponseProjection extends GraphQLResponseProjection {
public EventResponseProjection() {
}
+ public EventResponseProjection(EventResponseProjection projection) {
+ super(projection);
+ }
+
+ public EventResponseProjection(List projections) {
+ super(projections);
+ }
+
public EventResponseProjection id() {
return id(null);
}
public EventResponseProjection id(String alias) {
- fields.add(new GraphQLResponseField("id").alias(alias));
+ add$(new GraphQLResponseField("id").alias(alias));
return this;
}
@@ -30,7 +39,7 @@ public class EventResponseProjection extends GraphQLResponseProjection {
}
public EventResponseProjection categoryId(String alias) {
- fields.add(new GraphQLResponseField("categoryId").alias(alias));
+ add$(new GraphQLResponseField("categoryId").alias(alias));
return this;
}
@@ -39,7 +48,7 @@ public class EventResponseProjection extends GraphQLResponseProjection {
}
public EventResponseProjection properties(String alias, EventPropertyResponseProjection subProjection) {
- fields.add(new GraphQLResponseField("properties").alias(alias).projection(subProjection));
+ add$(new GraphQLResponseField("properties").alias(alias).projection(subProjection));
return this;
}
@@ -48,7 +57,7 @@ public class EventResponseProjection extends GraphQLResponseProjection {
}
public EventResponseProjection status(String alias) {
- fields.add(new GraphQLResponseField("status").alias(alias));
+ add$(new GraphQLResponseField("status").alias(alias));
return this;
}
@@ -57,7 +66,7 @@ public class EventResponseProjection extends GraphQLResponseProjection {
}
public EventResponseProjection createdBy(String alias) {
- fields.add(new GraphQLResponseField("createdBy").alias(alias));
+ add$(new GraphQLResponseField("createdBy").alias(alias));
return this;
}
@@ -66,7 +75,7 @@ public class EventResponseProjection extends GraphQLResponseProjection {
}
public EventResponseProjection createdDateTime(String alias) {
- fields.add(new GraphQLResponseField("createdDateTime").alias(alias));
+ add$(new GraphQLResponseField("createdDateTime").alias(alias));
return this;
}
@@ -75,7 +84,7 @@ public class EventResponseProjection extends GraphQLResponseProjection {
}
public EventResponseProjection active(String alias) {
- fields.add(new GraphQLResponseField("active").alias(alias));
+ add$(new GraphQLResponseField("active").alias(alias));
return this;
}
@@ -84,7 +93,7 @@ public class EventResponseProjection extends GraphQLResponseProjection {
}
public EventResponseProjection rating(String alias) {
- fields.add(new GraphQLResponseField("rating").alias(alias));
+ add$(new GraphQLResponseField("rating").alias(alias));
return this;
}
@@ -93,10 +102,15 @@ public class EventResponseProjection extends GraphQLResponseProjection {
}
public EventResponseProjection typename(String alias) {
- fields.add(new GraphQLResponseField("__typename").alias(alias));
+ add$(new GraphQLResponseField("__typename").alias(alias));
return this;
}
+ @Override
+ public EventResponseProjection deepCopy$() {
+ return new EventResponseProjection(this);
+ }
+
@Override
public boolean equals(Object obj) {
if (this == obj) {
@@ -114,4 +128,4 @@ public class EventResponseProjection extends GraphQLResponseProjection {
return Objects.hash(fields);
}
-}
+}
\ No newline at end of file
diff --git a/src/test/resources/expected-classes/request/ProductLinkCodeParametrizedInput.java.txt b/src/test/resources/expected-classes/request/ProductLinkCodeParametrizedInput.java.txt
index 6f51a4c69..2e415922c 100644
--- a/src/test/resources/expected-classes/request/ProductLinkCodeParametrizedInput.java.txt
+++ b/src/test/resources/expected-classes/request/ProductLinkCodeParametrizedInput.java.txt
@@ -28,6 +28,13 @@ public class ProductLinkCodeParametrizedInput implements GraphQLParametrizedInpu
return this;
}
+ @Override
+ public ProductLinkCodeParametrizedInput deepCopy() {
+ ProductLinkCodeParametrizedInput parametrizedInput = new ProductLinkCodeParametrizedInput();
+ parametrizedInput.pid(this.pid);
+ return parametrizedInput;
+ }
+
@Override
public String toString() {
diff --git a/src/test/resources/expected-classes/response/LocationResponseProjection.java.txt b/src/test/resources/expected-classes/response/LocationResponseProjection.java.txt
index 09147b077..0a31b1522 100644
--- a/src/test/resources/expected-classes/response/LocationResponseProjection.java.txt
+++ b/src/test/resources/expected-classes/response/LocationResponseProjection.java.txt
@@ -4,6 +4,7 @@ import com.kobylynskyi.graphql.codegen.model.graphql.GraphQLResponseField;
import com.kobylynskyi.graphql.codegen.model.graphql.GraphQLResponseProjection;
import java.util.HashMap;
import java.util.Map;
+import java.util.List;
/**
* Response projection for Location
@@ -19,6 +20,14 @@ public class LocationResponseProjection extends GraphQLResponseProjection {
public LocationResponseProjection() {
}
+ public LocationResponseProjection(LocationResponseProjection projection) {
+ super(projection);
+ }
+
+ public LocationResponseProjection(List projections) {
+ super(projections);
+ }
+
public LocationResponseProjection all$() {
return all$(3);
}
@@ -35,7 +44,7 @@ public class LocationResponseProjection extends GraphQLResponseProjection {
}
public LocationResponseProjection id(String alias) {
- fields.add(new GraphQLResponseField("id").alias(alias));
+ add$(new GraphQLResponseField("id").alias(alias));
return this;
}
@@ -44,7 +53,7 @@ public class LocationResponseProjection extends GraphQLResponseProjection {
}
public LocationResponseProjection locationType(String alias) {
- fields.add(new GraphQLResponseField("locationType").alias(alias));
+ add$(new GraphQLResponseField("locationType").alias(alias));
return this;
}
@@ -53,7 +62,7 @@ public class LocationResponseProjection extends GraphQLResponseProjection {
}
public LocationResponseProjection onCustomerLocation(String alias, CustomerLocationResponseProjection subProjection) {
- fields.add(new GraphQLResponseField("...on CustomerLocation").alias(alias).projection(subProjection));
+ add$(new GraphQLResponseField("...on CustomerLocation").alias(alias).projection(subProjection));
return this;
}
@@ -62,7 +71,7 @@ public class LocationResponseProjection extends GraphQLResponseProjection {
}
public LocationResponseProjection onDealerLocation(String alias, DealerLocationResponseProjection subProjection) {
- fields.add(new GraphQLResponseField("...on DealerLocation").alias(alias).projection(subProjection));
+ add$(new GraphQLResponseField("...on DealerLocation").alias(alias).projection(subProjection));
return this;
}
@@ -71,9 +80,14 @@ public class LocationResponseProjection extends GraphQLResponseProjection {
}
public LocationResponseProjection typename(String alias) {
- fields.add(new GraphQLResponseField("__typename").alias(alias));
+ add$(new GraphQLResponseField("__typename").alias(alias));
return this;
}
+ @Override
+ public LocationResponseProjection deepCopy$() {
+ return new LocationResponseProjection(this);
+ }
+
-}
+}
\ No newline at end of file
diff --git a/src/test/resources/expected-classes/response/SearchResultItemConnectionResponseProjection.java.txt b/src/test/resources/expected-classes/response/SearchResultItemConnectionResponseProjection.java.txt
index 953291fe4..05adac560 100644
--- a/src/test/resources/expected-classes/response/SearchResultItemConnectionResponseProjection.java.txt
+++ b/src/test/resources/expected-classes/response/SearchResultItemConnectionResponseProjection.java.txt
@@ -4,6 +4,7 @@ import com.kobylynskyi.graphql.codegen.model.graphql.GraphQLResponseField;
import com.kobylynskyi.graphql.codegen.model.graphql.GraphQLResponseProjection;
import java.util.HashMap;
import java.util.Map;
+import java.util.List;
/**
* Response projection for SearchResultItemConnection
@@ -19,6 +20,14 @@ public class SearchResultItemConnectionResponseProjection extends GraphQLRespons
public SearchResultItemConnectionResponseProjection() {
}
+ public SearchResultItemConnectionResponseProjection(SearchResultItemConnectionResponseProjection projection) {
+ super(projection);
+ }
+
+ public SearchResultItemConnectionResponseProjection(List projections) {
+ super(projections);
+ }
+
public SearchResultItemConnectionResponseProjection all$() {
return all$(3);
}
@@ -50,7 +59,7 @@ public class SearchResultItemConnectionResponseProjection extends GraphQLRespons
}
public SearchResultItemConnectionResponseProjection codeCount(String alias) {
- fields.add(new GraphQLResponseField("codeCount").alias(alias));
+ add$(new GraphQLResponseField("codeCount").alias(alias));
return this;
}
@@ -59,7 +68,7 @@ public class SearchResultItemConnectionResponseProjection extends GraphQLRespons
}
public SearchResultItemConnectionResponseProjection edges(String alias, SearchResultItemEdgeResponseProjection subProjection) {
- fields.add(new GraphQLResponseField("edges").alias(alias).projection(subProjection));
+ add$(new GraphQLResponseField("edges").alias(alias).projection(subProjection));
return this;
}
@@ -68,7 +77,7 @@ public class SearchResultItemConnectionResponseProjection extends GraphQLRespons
}
public SearchResultItemConnectionResponseProjection issueCount(String alias) {
- fields.add(new GraphQLResponseField("issueCount").alias(alias));
+ add$(new GraphQLResponseField("issueCount").alias(alias));
return this;
}
@@ -77,7 +86,7 @@ public class SearchResultItemConnectionResponseProjection extends GraphQLRespons
}
public SearchResultItemConnectionResponseProjection nodes(String alias, SearchResultItemResponseProjection subProjection) {
- fields.add(new GraphQLResponseField("nodes").alias(alias).projection(subProjection));
+ add$(new GraphQLResponseField("nodes").alias(alias).projection(subProjection));
return this;
}
@@ -86,7 +95,7 @@ public class SearchResultItemConnectionResponseProjection extends GraphQLRespons
}
public SearchResultItemConnectionResponseProjection pageInfo(String alias, PageInfoResponseProjection subProjection) {
- fields.add(new GraphQLResponseField("pageInfo").alias(alias).projection(subProjection));
+ add$(new GraphQLResponseField("pageInfo").alias(alias).projection(subProjection));
return this;
}
@@ -95,7 +104,7 @@ public class SearchResultItemConnectionResponseProjection extends GraphQLRespons
}
public SearchResultItemConnectionResponseProjection repositoryCount(String alias) {
- fields.add(new GraphQLResponseField("repositoryCount").alias(alias));
+ add$(new GraphQLResponseField("repositoryCount").alias(alias));
return this;
}
@@ -104,7 +113,7 @@ public class SearchResultItemConnectionResponseProjection extends GraphQLRespons
}
public SearchResultItemConnectionResponseProjection userCount(String alias) {
- fields.add(new GraphQLResponseField("userCount").alias(alias));
+ add$(new GraphQLResponseField("userCount").alias(alias));
return this;
}
@@ -113,7 +122,7 @@ public class SearchResultItemConnectionResponseProjection extends GraphQLRespons
}
public SearchResultItemConnectionResponseProjection wikiCount(String alias) {
- fields.add(new GraphQLResponseField("wikiCount").alias(alias));
+ add$(new GraphQLResponseField("wikiCount").alias(alias));
return this;
}
@@ -122,9 +131,14 @@ public class SearchResultItemConnectionResponseProjection extends GraphQLRespons
}
public SearchResultItemConnectionResponseProjection typename(String alias) {
- fields.add(new GraphQLResponseField("__typename").alias(alias));
+ add$(new GraphQLResponseField("__typename").alias(alias));
return this;
}
+ @Override
+ public SearchResultItemConnectionResponseProjection deepCopy$() {
+ return new SearchResultItemConnectionResponseProjection(this);
+ }
+
-}
+}
\ No newline at end of file
diff --git a/src/test/resources/expected-classes/response/SearchResultItemResponseProjection.java.txt b/src/test/resources/expected-classes/response/SearchResultItemResponseProjection.java.txt
index a0ae71590..61fa7fee5 100644
--- a/src/test/resources/expected-classes/response/SearchResultItemResponseProjection.java.txt
+++ b/src/test/resources/expected-classes/response/SearchResultItemResponseProjection.java.txt
@@ -4,6 +4,7 @@ import com.kobylynskyi.graphql.codegen.model.graphql.GraphQLResponseField;
import com.kobylynskyi.graphql.codegen.model.graphql.GraphQLResponseProjection;
import java.util.HashMap;
import java.util.Map;
+import java.util.List;
/**
* Response projection for SearchResultItem
@@ -19,6 +20,14 @@ public class SearchResultItemResponseProjection extends GraphQLResponseProjectio
public SearchResultItemResponseProjection() {
}
+ public SearchResultItemResponseProjection(SearchResultItemResponseProjection projection) {
+ super(projection);
+ }
+
+ public SearchResultItemResponseProjection(List projections) {
+ super(projections);
+ }
+
public SearchResultItemResponseProjection all$() {
return all$(3);
}
@@ -33,7 +42,7 @@ public class SearchResultItemResponseProjection extends GraphQLResponseProjectio
}
public SearchResultItemResponseProjection onApp(String alias, AppResponseProjection subProjection) {
- fields.add(new GraphQLResponseField("...on App").alias(alias).projection(subProjection));
+ add$(new GraphQLResponseField("...on App").alias(alias).projection(subProjection));
return this;
}
@@ -42,7 +51,7 @@ public class SearchResultItemResponseProjection extends GraphQLResponseProjectio
}
public SearchResultItemResponseProjection onRepository(String alias, RepositoryResponseProjection subProjection) {
- fields.add(new GraphQLResponseField("...on Repository").alias(alias).projection(subProjection));
+ add$(new GraphQLResponseField("...on Repository").alias(alias).projection(subProjection));
return this;
}
@@ -51,7 +60,7 @@ public class SearchResultItemResponseProjection extends GraphQLResponseProjectio
}
public SearchResultItemResponseProjection onIssue(String alias, IssueResponseProjection subProjection) {
- fields.add(new GraphQLResponseField("...on Issue").alias(alias).projection(subProjection));
+ add$(new GraphQLResponseField("...on Issue").alias(alias).projection(subProjection));
return this;
}
@@ -60,7 +69,7 @@ public class SearchResultItemResponseProjection extends GraphQLResponseProjectio
}
public SearchResultItemResponseProjection onOrganization(String alias, OrganizationResponseProjection subProjection) {
- fields.add(new GraphQLResponseField("...on Organization").alias(alias).projection(subProjection));
+ add$(new GraphQLResponseField("...on Organization").alias(alias).projection(subProjection));
return this;
}
@@ -69,7 +78,7 @@ public class SearchResultItemResponseProjection extends GraphQLResponseProjectio
}
public SearchResultItemResponseProjection onUser(String alias, UserResponseProjection subProjection) {
- fields.add(new GraphQLResponseField("...on User").alias(alias).projection(subProjection));
+ add$(new GraphQLResponseField("...on User").alias(alias).projection(subProjection));
return this;
}
@@ -78,7 +87,7 @@ public class SearchResultItemResponseProjection extends GraphQLResponseProjectio
}
public SearchResultItemResponseProjection onMarketplaceListing(String alias, MarketplaceListingResponseProjection subProjection) {
- fields.add(new GraphQLResponseField("...on MarketplaceListing").alias(alias).projection(subProjection));
+ add$(new GraphQLResponseField("...on MarketplaceListing").alias(alias).projection(subProjection));
return this;
}
@@ -87,7 +96,7 @@ public class SearchResultItemResponseProjection extends GraphQLResponseProjectio
}
public SearchResultItemResponseProjection onPullRequest(String alias, PullRequestResponseProjection subProjection) {
- fields.add(new GraphQLResponseField("...on PullRequest").alias(alias).projection(subProjection));
+ add$(new GraphQLResponseField("...on PullRequest").alias(alias).projection(subProjection));
return this;
}
@@ -96,9 +105,14 @@ public class SearchResultItemResponseProjection extends GraphQLResponseProjectio
}
public SearchResultItemResponseProjection typename(String alias) {
- fields.add(new GraphQLResponseField("__typename").alias(alias));
+ add$(new GraphQLResponseField("__typename").alias(alias));
return this;
}
+ @Override
+ public SearchResultItemResponseProjection deepCopy$() {
+ return new SearchResultItemResponseProjection(this);
+ }
+
-}
+}
\ No newline at end of file
diff --git a/src/test/resources/expected-classes/response/VehicleResponseProjection.java.txt b/src/test/resources/expected-classes/response/VehicleResponseProjection.java.txt
index b8027a9f8..40831cca3 100644
--- a/src/test/resources/expected-classes/response/VehicleResponseProjection.java.txt
+++ b/src/test/resources/expected-classes/response/VehicleResponseProjection.java.txt
@@ -4,6 +4,7 @@ import com.kobylynskyi.graphql.codegen.model.graphql.GraphQLResponseField;
import com.kobylynskyi.graphql.codegen.model.graphql.GraphQLResponseProjection;
import java.util.HashMap;
import java.util.Map;
+import java.util.List;
/**
* Response projection for Vehicle
@@ -19,6 +20,14 @@ public class VehicleResponseProjection extends GraphQLResponseProjection {
public VehicleResponseProjection() {
}
+ public VehicleResponseProjection(VehicleResponseProjection projection) {
+ super(projection);
+ }
+
+ public VehicleResponseProjection(List projections) {
+ super(projections);
+ }
+
public VehicleResponseProjection all$() {
return all$(3);
}
@@ -39,7 +48,7 @@ public class VehicleResponseProjection extends GraphQLResponseProjection {
}
public VehicleResponseProjection vehicleId(String alias) {
- fields.add(new GraphQLResponseField("vehicleId").alias(alias));
+ add$(new GraphQLResponseField("vehicleId").alias(alias));
return this;
}
@@ -48,7 +57,7 @@ public class VehicleResponseProjection extends GraphQLResponseProjection {
}
public VehicleResponseProjection registrationNumber(String alias) {
- fields.add(new GraphQLResponseField("registrationNumber").alias(alias));
+ add$(new GraphQLResponseField("registrationNumber").alias(alias));
return this;
}
@@ -57,7 +66,7 @@ public class VehicleResponseProjection extends GraphQLResponseProjection {
}
public VehicleResponseProjection location(String alias, LocationResponseProjection subProjection) {
- fields.add(new GraphQLResponseField("location").alias(alias).projection(subProjection));
+ add$(new GraphQLResponseField("location").alias(alias).projection(subProjection));
return this;
}
@@ -66,9 +75,14 @@ public class VehicleResponseProjection extends GraphQLResponseProjection {
}
public VehicleResponseProjection typename(String alias) {
- fields.add(new GraphQLResponseField("__typename").alias(alias));
+ add$(new GraphQLResponseField("__typename").alias(alias));
return this;
}
+ @Override
+ public VehicleResponseProjection deepCopy$() {
+ return new VehicleResponseProjection(this);
+ }
+
-}
+}
\ No newline at end of file
diff --git a/src/test/resources/expected-classes/restricted-words/CharResponseProjection.java.txt b/src/test/resources/expected-classes/restricted-words/CharResponseProjection.java.txt
index 11fa4b04c..001932785 100644
--- a/src/test/resources/expected-classes/restricted-words/CharResponseProjection.java.txt
+++ b/src/test/resources/expected-classes/restricted-words/CharResponseProjection.java.txt
@@ -4,6 +4,7 @@ import com.kobylynskyi.graphql.codegen.model.graphql.GraphQLResponseField;
import com.kobylynskyi.graphql.codegen.model.graphql.GraphQLResponseProjection;
import java.util.HashMap;
import java.util.Map;
+import java.util.List;
import java.util.Objects;
/**
@@ -20,6 +21,14 @@ public class CharResponseProjection extends GraphQLResponseProjection {
public CharResponseProjection() {
}
+ public CharResponseProjection(CharResponseProjection projection) {
+ super(projection);
+ }
+
+ public CharResponseProjection(List projections) {
+ super(projections);
+ }
+
public CharResponseProjection all$() {
return all$(3);
}
@@ -34,10 +43,15 @@ public class CharResponseProjection extends GraphQLResponseProjection {
}
public CharResponseProjection typename(String alias) {
- fields.add(new GraphQLResponseField("__typename").alias(alias));
+ add$(new GraphQLResponseField("__typename").alias(alias));
return this;
}
+ @Override
+ public CharResponseProjection deepCopy$() {
+ return new CharResponseProjection(this);
+ }
+
@Override
public boolean equals(Object obj) {
if (this == obj) {
@@ -55,4 +69,4 @@ public class CharResponseProjection extends GraphQLResponseProjection {
return Objects.hash(fields);
}
-}
+}
\ No newline at end of file
diff --git a/src/test/resources/expected-classes/restricted-words/QueryCaseParametrizedInput.java.txt b/src/test/resources/expected-classes/restricted-words/QueryCaseParametrizedInput.java.txt
index 783a99a83..4f8586f20 100644
--- a/src/test/resources/expected-classes/restricted-words/QueryCaseParametrizedInput.java.txt
+++ b/src/test/resources/expected-classes/restricted-words/QueryCaseParametrizedInput.java.txt
@@ -28,6 +28,13 @@ public class QueryCaseParametrizedInput implements GraphQLParametrizedInput {
return this;
}
+ @Override
+ public QueryCaseParametrizedInput deepCopy() {
+ QueryCaseParametrizedInput parametrizedInput = new QueryCaseParametrizedInput();
+ parametrizedInput.Final(this.Final);
+ return parametrizedInput;
+ }
+
@Override
public boolean equals(Object obj) {
if (this == obj) {
@@ -54,4 +61,4 @@ public class QueryCaseParametrizedInput implements GraphQLParametrizedInput {
return joiner.toString();
}
-}
+}
\ No newline at end of file
diff --git a/src/test/resources/expected-classes/restricted-words/QueryPrivateParametrizedInput.java.txt b/src/test/resources/expected-classes/restricted-words/QueryPrivateParametrizedInput.java.txt
index b0b8cacc1..300789a5c 100644
--- a/src/test/resources/expected-classes/restricted-words/QueryPrivateParametrizedInput.java.txt
+++ b/src/test/resources/expected-classes/restricted-words/QueryPrivateParametrizedInput.java.txt
@@ -42,6 +42,15 @@ public class QueryPrivateParametrizedInput implements GraphQLParametrizedInput {
return this;
}
+ @Override
+ public QueryPrivateParametrizedInput deepCopy() {
+ QueryPrivateParametrizedInput parametrizedInput = new QueryPrivateParametrizedInput();
+ parametrizedInput.Int(this.Int);
+ parametrizedInput.New(this.New);
+ parametrizedInput.Enum(this.Enum);
+ return parametrizedInput;
+ }
+
@Override
public boolean equals(Object obj) {
if (this == obj) {
diff --git a/src/test/resources/expected-classes/restricted-words/QueryResponseProjection.java.txt b/src/test/resources/expected-classes/restricted-words/QueryResponseProjection.java.txt
index 310ee9c16..a2cbd0e07 100644
--- a/src/test/resources/expected-classes/restricted-words/QueryResponseProjection.java.txt
+++ b/src/test/resources/expected-classes/restricted-words/QueryResponseProjection.java.txt
@@ -4,6 +4,7 @@ import com.kobylynskyi.graphql.codegen.model.graphql.GraphQLResponseField;
import com.kobylynskyi.graphql.codegen.model.graphql.GraphQLResponseProjection;
import java.util.HashMap;
import java.util.Map;
+import java.util.List;
import java.util.Objects;
/**
@@ -20,6 +21,14 @@ public class QueryResponseProjection extends GraphQLResponseProjection {
public QueryResponseProjection() {
}
+ public QueryResponseProjection(QueryResponseProjection projection) {
+ super(projection);
+ }
+
+ public QueryResponseProjection(List projections) {
+ super(projections);
+ }
+
public QueryResponseProjection all$() {
return all$(3);
}
@@ -40,7 +49,7 @@ public class QueryResponseProjection extends GraphQLResponseProjection {
}
public QueryResponseProjection Native(String alias) {
- fields.add(new GraphQLResponseField("native").alias(alias));
+ add$(new GraphQLResponseField("native").alias(alias));
return this;
}
@@ -49,7 +58,7 @@ public class QueryResponseProjection extends GraphQLResponseProjection {
}
public QueryResponseProjection Private(String alias, SynchronizedResponseProjection subProjection) {
- fields.add(new GraphQLResponseField("private").alias(alias).projection(subProjection));
+ add$(new GraphQLResponseField("private").alias(alias).projection(subProjection));
return this;
}
@@ -58,7 +67,7 @@ public class QueryResponseProjection extends GraphQLResponseProjection {
}
public QueryResponseProjection Private(String alias, QueryPrivateParametrizedInput input, SynchronizedResponseProjection subProjection) {
- fields.add(new GraphQLResponseField("private").alias(alias).parameters(input).projection(subProjection));
+ add$(new GraphQLResponseField("private").alias(alias).parameters(input).projection(subProjection));
return this;
}
@@ -67,7 +76,7 @@ public class QueryResponseProjection extends GraphQLResponseProjection {
}
public QueryResponseProjection Case(String alias) {
- fields.add(new GraphQLResponseField("case").alias(alias));
+ add$(new GraphQLResponseField("case").alias(alias));
return this;
}
@@ -76,7 +85,7 @@ public class QueryResponseProjection extends GraphQLResponseProjection {
}
public QueryResponseProjection Case(String alias, QueryCaseParametrizedInput input) {
- fields.add(new GraphQLResponseField("case").alias(alias).parameters(input));
+ add$(new GraphQLResponseField("case").alias(alias).parameters(input));
return this;
}
@@ -85,10 +94,15 @@ public class QueryResponseProjection extends GraphQLResponseProjection {
}
public QueryResponseProjection typename(String alias) {
- fields.add(new GraphQLResponseField("__typename").alias(alias));
+ add$(new GraphQLResponseField("__typename").alias(alias));
return this;
}
+ @Override
+ public QueryResponseProjection deepCopy$() {
+ return new QueryResponseProjection(this);
+ }
+
@Override
public boolean equals(Object obj) {
if (this == obj) {
@@ -106,4 +120,4 @@ public class QueryResponseProjection extends GraphQLResponseProjection {
return Objects.hash(fields);
}
-}
+}
\ No newline at end of file
diff --git a/src/test/resources/expected-classes/restricted-words/SynchronizedResponseProjection.java.txt b/src/test/resources/expected-classes/restricted-words/SynchronizedResponseProjection.java.txt
index 709b6a507..13927c861 100644
--- a/src/test/resources/expected-classes/restricted-words/SynchronizedResponseProjection.java.txt
+++ b/src/test/resources/expected-classes/restricted-words/SynchronizedResponseProjection.java.txt
@@ -4,6 +4,7 @@ import com.kobylynskyi.graphql.codegen.model.graphql.GraphQLResponseField;
import com.kobylynskyi.graphql.codegen.model.graphql.GraphQLResponseProjection;
import java.util.HashMap;
import java.util.Map;
+import java.util.List;
import java.util.Objects;
/**
@@ -20,6 +21,14 @@ public class SynchronizedResponseProjection extends GraphQLResponseProjection {
public SynchronizedResponseProjection() {
}
+ public SynchronizedResponseProjection(SynchronizedResponseProjection projection) {
+ super(projection);
+ }
+
+ public SynchronizedResponseProjection(List projections) {
+ super(projections);
+ }
+
public SynchronizedResponseProjection all$() {
return all$(3);
}
@@ -40,7 +49,7 @@ public class SynchronizedResponseProjection extends GraphQLResponseProjection {
}
public SynchronizedResponseProjection Void(String alias) {
- fields.add(new GraphQLResponseField("void").alias(alias));
+ add$(new GraphQLResponseField("void").alias(alias));
return this;
}
@@ -49,7 +58,7 @@ public class SynchronizedResponseProjection extends GraphQLResponseProjection {
}
public SynchronizedResponseProjection Wait(String alias, CharResponseProjection subProjection) {
- fields.add(new GraphQLResponseField("wait").alias(alias).projection(subProjection));
+ add$(new GraphQLResponseField("wait").alias(alias).projection(subProjection));
return this;
}
@@ -58,7 +67,7 @@ public class SynchronizedResponseProjection extends GraphQLResponseProjection {
}
public SynchronizedResponseProjection Class(String alias) {
- fields.add(new GraphQLResponseField("class").alias(alias));
+ add$(new GraphQLResponseField("class").alias(alias));
return this;
}
@@ -67,10 +76,15 @@ public class SynchronizedResponseProjection extends GraphQLResponseProjection {
}
public SynchronizedResponseProjection typename(String alias) {
- fields.add(new GraphQLResponseField("__typename").alias(alias));
+ add$(new GraphQLResponseField("__typename").alias(alias));
return this;
}
+ @Override
+ public SynchronizedResponseProjection deepCopy$() {
+ return new SynchronizedResponseProjection(this);
+ }
+
@Override
public boolean equals(Object obj) {
if (this == obj) {
diff --git a/src/test/resources/expected-classes/scala/SearchResultItemConnectionResponseProjection.scala.txt b/src/test/resources/expected-classes/scala/SearchResultItemConnectionResponseProjection.scala.txt
index ae5328c2c..4cfc5a3c9 100644
--- a/src/test/resources/expected-classes/scala/SearchResultItemConnectionResponseProjection.scala.txt
+++ b/src/test/resources/expected-classes/scala/SearchResultItemConnectionResponseProjection.scala.txt
@@ -4,6 +4,7 @@ import com.kobylynskyi.graphql.codegen.model.graphql.GraphQLResponseField
import com.kobylynskyi.graphql.codegen.model.graphql.GraphQLResponseProjection
import java.util.Objects
import scala.collection.mutable.HashMap
+import scala.collection.JavaConverters._
/**
* Response projection for SearchResultItemConnection
@@ -12,7 +13,29 @@ import scala.collection.mutable.HashMap
value = Array("com.kobylynskyi.graphql.codegen.GraphQLCodegen"),
date = "2020-12-31T23:59:59-0500"
)
-class SearchResultItemConnectionResponseProjection extends GraphQLResponseProjection {
+class SearchResultItemConnectionResponseProjection() extends GraphQLResponseProjection() {
+
+ def this(projection: SearchResultItemConnectionResponseProjection) = {
+ this()
+ if (projection != null) {
+ for (field <- projection.fields.values.asScala) {
+ add$(field)
+ }
+ }
+ }
+
+ def this(projections: scala.Seq[SearchResultItemConnectionResponseProjection]) = {
+ this()
+ if (projections != null) {
+ for (projection <- projections) {
+ if (projection != null) {
+ for (field <- projection.fields.values.asScala) {
+ add$(field)
+ }
+ }
+ }
+ }
+ }
private final lazy val projectionDepthOnFields = new HashMap[String, Int]
@@ -45,7 +68,7 @@ class SearchResultItemConnectionResponseProjection extends GraphQLResponseProjec
}
def codeCount(alias: String): SearchResultItemConnectionResponseProjection = {
- fields.add(new GraphQLResponseField("codeCount").alias(alias))
+ add$(new GraphQLResponseField("codeCount").alias(alias))
this
}
@@ -54,7 +77,7 @@ class SearchResultItemConnectionResponseProjection extends GraphQLResponseProjec
}
def edges(alias: String, subProjection: SearchResultItemEdgeResponseProjection): SearchResultItemConnectionResponseProjection = {
- fields.add(new GraphQLResponseField("edges").alias(alias).projection(subProjection))
+ add$(new GraphQLResponseField("edges").alias(alias).projection(subProjection))
this
}
@@ -63,7 +86,7 @@ class SearchResultItemConnectionResponseProjection extends GraphQLResponseProjec
}
def issueCount(alias: String): SearchResultItemConnectionResponseProjection = {
- fields.add(new GraphQLResponseField("issueCount").alias(alias))
+ add$(new GraphQLResponseField("issueCount").alias(alias))
this
}
@@ -72,7 +95,7 @@ class SearchResultItemConnectionResponseProjection extends GraphQLResponseProjec
}
def nodes(alias: String, subProjection: SearchResultItemResponseProjection): SearchResultItemConnectionResponseProjection = {
- fields.add(new GraphQLResponseField("nodes").alias(alias).projection(subProjection))
+ add$(new GraphQLResponseField("nodes").alias(alias).projection(subProjection))
this
}
@@ -81,7 +104,7 @@ class SearchResultItemConnectionResponseProjection extends GraphQLResponseProjec
}
def pageInfo(alias: String, subProjection: PageInfoResponseProjection): SearchResultItemConnectionResponseProjection = {
- fields.add(new GraphQLResponseField("pageInfo").alias(alias).projection(subProjection))
+ add$(new GraphQLResponseField("pageInfo").alias(alias).projection(subProjection))
this
}
@@ -90,7 +113,7 @@ class SearchResultItemConnectionResponseProjection extends GraphQLResponseProjec
}
def repositoryCount(alias: String): SearchResultItemConnectionResponseProjection = {
- fields.add(new GraphQLResponseField("repositoryCount").alias(alias))
+ add$(new GraphQLResponseField("repositoryCount").alias(alias))
this
}
@@ -99,7 +122,7 @@ class SearchResultItemConnectionResponseProjection extends GraphQLResponseProjec
}
def userCount(alias: String): SearchResultItemConnectionResponseProjection = {
- fields.add(new GraphQLResponseField("userCount").alias(alias))
+ add$(new GraphQLResponseField("userCount").alias(alias))
this
}
@@ -108,7 +131,7 @@ class SearchResultItemConnectionResponseProjection extends GraphQLResponseProjec
}
def wikiCount(alias: String): SearchResultItemConnectionResponseProjection = {
- fields.add(new GraphQLResponseField("wikiCount").alias(alias))
+ add$(new GraphQLResponseField("wikiCount").alias(alias))
this
}
@@ -117,10 +140,12 @@ class SearchResultItemConnectionResponseProjection extends GraphQLResponseProjec
}
def typename(alias: String): SearchResultItemConnectionResponseProjection = {
- fields.add(new GraphQLResponseField("__typename").alias(alias))
+ add$(new GraphQLResponseField("__typename").alias(alias))
this
}
+ override def deepCopy$(): SearchResultItemConnectionResponseProjection = new SearchResultItemConnectionResponseProjection(this)
+
override def equals(obj: Any): Boolean = {
if (this == obj) {
return true
@@ -134,4 +159,4 @@ class SearchResultItemConnectionResponseProjection extends GraphQLResponseProjec
override def hashCode(): Int = Objects.hash(fields)
-}
+}
\ No newline at end of file
diff --git a/src/test/resources/expected-classes/scala/SearchResultItemResponseProjection.scala.txt b/src/test/resources/expected-classes/scala/SearchResultItemResponseProjection.scala.txt
index 6b0f6ed80..2bf268c22 100644
--- a/src/test/resources/expected-classes/scala/SearchResultItemResponseProjection.scala.txt
+++ b/src/test/resources/expected-classes/scala/SearchResultItemResponseProjection.scala.txt
@@ -4,6 +4,7 @@ import com.kobylynskyi.graphql.codegen.model.graphql.GraphQLResponseField
import com.kobylynskyi.graphql.codegen.model.graphql.GraphQLResponseProjection
import java.util.Objects
import scala.collection.mutable.HashMap
+import scala.collection.JavaConverters._
/**
* Response projection for SearchResultItem
@@ -12,7 +13,29 @@ import scala.collection.mutable.HashMap
value = Array("com.kobylynskyi.graphql.codegen.GraphQLCodegen"),
date = "2020-12-31T23:59:59-0500"
)
-class SearchResultItemResponseProjection extends GraphQLResponseProjection {
+class SearchResultItemResponseProjection() extends GraphQLResponseProjection() {
+
+ def this(projection: SearchResultItemResponseProjection) = {
+ this()
+ if (projection != null) {
+ for (field <- projection.fields.values.asScala) {
+ add$(field)
+ }
+ }
+ }
+
+ def this(projections: scala.Seq[SearchResultItemResponseProjection]) = {
+ this()
+ if (projections != null) {
+ for (projection <- projections) {
+ if (projection != null) {
+ for (field <- projection.fields.values.asScala) {
+ add$(field)
+ }
+ }
+ }
+ }
+ }
private final lazy val projectionDepthOnFields = new HashMap[String, Int]
@@ -28,7 +51,7 @@ class SearchResultItemResponseProjection extends GraphQLResponseProjection {
}
def onApp(alias: String, subProjection: AppResponseProjection): SearchResultItemResponseProjection = {
- fields.add(new GraphQLResponseField("...on App").alias(alias).projection(subProjection))
+ add$(new GraphQLResponseField("...on App").alias(alias).projection(subProjection))
this
}
@@ -37,7 +60,7 @@ class SearchResultItemResponseProjection extends GraphQLResponseProjection {
}
def onRepository(alias: String, subProjection: RepositoryResponseProjection): SearchResultItemResponseProjection = {
- fields.add(new GraphQLResponseField("...on Repository").alias(alias).projection(subProjection))
+ add$(new GraphQLResponseField("...on Repository").alias(alias).projection(subProjection))
this
}
@@ -46,7 +69,7 @@ class SearchResultItemResponseProjection extends GraphQLResponseProjection {
}
def onIssue(alias: String, subProjection: IssueResponseProjection): SearchResultItemResponseProjection = {
- fields.add(new GraphQLResponseField("...on Issue").alias(alias).projection(subProjection))
+ add$(new GraphQLResponseField("...on Issue").alias(alias).projection(subProjection))
this
}
@@ -55,7 +78,7 @@ class SearchResultItemResponseProjection extends GraphQLResponseProjection {
}
def onOrganization(alias: String, subProjection: OrganizationResponseProjection): SearchResultItemResponseProjection = {
- fields.add(new GraphQLResponseField("...on Organization").alias(alias).projection(subProjection))
+ add$(new GraphQLResponseField("...on Organization").alias(alias).projection(subProjection))
this
}
@@ -64,7 +87,7 @@ class SearchResultItemResponseProjection extends GraphQLResponseProjection {
}
def onUser(alias: String, subProjection: UserResponseProjection): SearchResultItemResponseProjection = {
- fields.add(new GraphQLResponseField("...on User").alias(alias).projection(subProjection))
+ add$(new GraphQLResponseField("...on User").alias(alias).projection(subProjection))
this
}
@@ -73,7 +96,7 @@ class SearchResultItemResponseProjection extends GraphQLResponseProjection {
}
def onMarketplaceListing(alias: String, subProjection: MarketplaceListingResponseProjection): SearchResultItemResponseProjection = {
- fields.add(new GraphQLResponseField("...on MarketplaceListing").alias(alias).projection(subProjection))
+ add$(new GraphQLResponseField("...on MarketplaceListing").alias(alias).projection(subProjection))
this
}
@@ -82,7 +105,7 @@ class SearchResultItemResponseProjection extends GraphQLResponseProjection {
}
def onPullRequest(alias: String, subProjection: PullRequestResponseProjection): SearchResultItemResponseProjection = {
- fields.add(new GraphQLResponseField("...on PullRequest").alias(alias).projection(subProjection))
+ add$(new GraphQLResponseField("...on PullRequest").alias(alias).projection(subProjection))
this
}
@@ -91,10 +114,12 @@ class SearchResultItemResponseProjection extends GraphQLResponseProjection {
}
def typename(alias: String): SearchResultItemResponseProjection = {
- fields.add(new GraphQLResponseField("__typename").alias(alias))
+ add$(new GraphQLResponseField("__typename").alias(alias))
this
}
+ override def deepCopy$(): SearchResultItemResponseProjection = new SearchResultItemResponseProjection(this)
+
override def equals(obj: Any): Boolean = {
if (this == obj) {
return true
@@ -108,4 +133,4 @@ class SearchResultItemResponseProjection extends GraphQLResponseProjection {
override def hashCode(): Int = Objects.hash(fields)
-}
+}
\ No newline at end of file
diff --git a/src/test/resources/expected-classes/scala/empty/EventResponseProjection.scala.txt b/src/test/resources/expected-classes/scala/empty/EventResponseProjection.scala.txt
index 372ac4910..37a91a039 100644
--- a/src/test/resources/expected-classes/scala/empty/EventResponseProjection.scala.txt
+++ b/src/test/resources/expected-classes/scala/empty/EventResponseProjection.scala.txt
@@ -1,6 +1,7 @@
import com.kobylynskyi.graphql.codegen.model.graphql.GraphQLResponseField
import com.kobylynskyi.graphql.codegen.model.graphql.GraphQLResponseProjection
import scala.collection.mutable.HashMap
+import scala.collection.JavaConverters._
/**
* Response projection for Event
@@ -9,7 +10,29 @@ import scala.collection.mutable.HashMap
value = Array("com.kobylynskyi.graphql.codegen.GraphQLCodegen"),
date = "2020-12-31T23:59:59-0500"
)
-class EventResponseProjection extends GraphQLResponseProjection {
+class EventResponseProjection() extends GraphQLResponseProjection() {
+
+ def this(projection: EventResponseProjection) = {
+ this()
+ if (projection != null) {
+ for (field <- projection.fields.values.asScala) {
+ add$(field)
+ }
+ }
+ }
+
+ def this(projections: scala.Seq[EventResponseProjection]) = {
+ this()
+ if (projections != null) {
+ for (projection <- projections) {
+ if (projection != null) {
+ for (field <- projection.fields.values.asScala) {
+ add$(field)
+ }
+ }
+ }
+ }
+ }
private final lazy val projectionDepthOnFields = new HashMap[String, Int]
@@ -25,9 +48,11 @@ class EventResponseProjection extends GraphQLResponseProjection {
}
def typename(alias: String): EventResponseProjection = {
- fields.add(new GraphQLResponseField("__typename").alias(alias))
+ add$(new GraphQLResponseField("__typename").alias(alias))
this
}
+ override def deepCopy$(): EventResponseProjection = new EventResponseProjection(this)
+
-}
+}
\ No newline at end of file
diff --git a/src/test/resources/expected-classes/scala/extend/request/AssetResponseProjection.scala.txt b/src/test/resources/expected-classes/scala/extend/request/AssetResponseProjection.scala.txt
index f6cb74a64..fbbefc84c 100644
--- a/src/test/resources/expected-classes/scala/extend/request/AssetResponseProjection.scala.txt
+++ b/src/test/resources/expected-classes/scala/extend/request/AssetResponseProjection.scala.txt
@@ -1,6 +1,7 @@
import com.kobylynskyi.graphql.codegen.model.graphql.GraphQLResponseField
import com.kobylynskyi.graphql.codegen.model.graphql.GraphQLResponseProjection
import scala.collection.mutable.HashMap
+import scala.collection.JavaConverters._
/**
* Response projection for Asset
@@ -9,7 +10,29 @@ import scala.collection.mutable.HashMap
value = Array("com.kobylynskyi.graphql.codegen.GraphQLCodegen"),
date = "2020-12-31T23:59:59-0500"
)
-class AssetResponseProjection extends GraphQLResponseProjection {
+class AssetResponseProjection() extends GraphQLResponseProjection() {
+
+ def this(projection: AssetResponseProjection) = {
+ this()
+ if (projection != null) {
+ for (field <- projection.fields.values.asScala) {
+ add$(field)
+ }
+ }
+ }
+
+ def this(projections: scala.Seq[AssetResponseProjection]) = {
+ this()
+ if (projections != null) {
+ for (projection <- projections) {
+ if (projection != null) {
+ for (field <- projection.fields.values.asScala) {
+ add$(field)
+ }
+ }
+ }
+ }
+ }
private final lazy val projectionDepthOnFields = new HashMap[String, Int]
@@ -29,7 +52,7 @@ class AssetResponseProjection extends GraphQLResponseProjection {
}
def name(alias: String): AssetResponseProjection = {
- fields.add(new GraphQLResponseField("name").alias(alias))
+ add$(new GraphQLResponseField("name").alias(alias))
this
}
@@ -38,7 +61,7 @@ class AssetResponseProjection extends GraphQLResponseProjection {
}
def status(alias: String): AssetResponseProjection = {
- fields.add(new GraphQLResponseField("status").alias(alias))
+ add$(new GraphQLResponseField("status").alias(alias))
this
}
@@ -47,7 +70,7 @@ class AssetResponseProjection extends GraphQLResponseProjection {
}
def id(alias: String): AssetResponseProjection = {
- fields.add(new GraphQLResponseField("id").alias(alias))
+ add$(new GraphQLResponseField("id").alias(alias))
this
}
@@ -56,7 +79,7 @@ class AssetResponseProjection extends GraphQLResponseProjection {
}
def createdBy(alias: String): AssetResponseProjection = {
- fields.add(new GraphQLResponseField("createdBy").alias(alias))
+ add$(new GraphQLResponseField("createdBy").alias(alias))
this
}
@@ -65,9 +88,11 @@ class AssetResponseProjection extends GraphQLResponseProjection {
}
def typename(alias: String): AssetResponseProjection = {
- fields.add(new GraphQLResponseField("__typename").alias(alias))
+ add$(new GraphQLResponseField("__typename").alias(alias))
this
}
+ override def deepCopy$(): AssetResponseProjection = new AssetResponseProjection(this)
+
-}
+}
\ No newline at end of file
diff --git a/src/test/resources/expected-classes/scala/extend/request/EventResponseProjection.scala.txt b/src/test/resources/expected-classes/scala/extend/request/EventResponseProjection.scala.txt
index 1e25331b1..8a8020f3e 100644
--- a/src/test/resources/expected-classes/scala/extend/request/EventResponseProjection.scala.txt
+++ b/src/test/resources/expected-classes/scala/extend/request/EventResponseProjection.scala.txt
@@ -1,6 +1,7 @@
import com.kobylynskyi.graphql.codegen.model.graphql.GraphQLResponseField
import com.kobylynskyi.graphql.codegen.model.graphql.GraphQLResponseProjection
import scala.collection.mutable.HashMap
+import scala.collection.JavaConverters._
/**
* Response projection for Event
@@ -9,7 +10,29 @@ import scala.collection.mutable.HashMap
value = Array("com.kobylynskyi.graphql.codegen.GraphQLCodegen"),
date = "2020-12-31T23:59:59-0500"
)
-class EventResponseProjection extends GraphQLResponseProjection {
+class EventResponseProjection() extends GraphQLResponseProjection() {
+
+ def this(projection: EventResponseProjection) = {
+ this()
+ if (projection != null) {
+ for (field <- projection.fields.values.asScala) {
+ add$(field)
+ }
+ }
+ }
+
+ def this(projections: scala.Seq[EventResponseProjection]) = {
+ this()
+ if (projections != null) {
+ for (projection <- projections) {
+ if (projection != null) {
+ for (field <- projection.fields.values.asScala) {
+ add$(field)
+ }
+ }
+ }
+ }
+ }
private final lazy val projectionDepthOnFields = new HashMap[String, Int]
@@ -33,7 +56,7 @@ class EventResponseProjection extends GraphQLResponseProjection {
}
def status(alias: String): EventResponseProjection = {
- fields.add(new GraphQLResponseField("status").alias(alias))
+ add$(new GraphQLResponseField("status").alias(alias))
this
}
@@ -42,7 +65,7 @@ class EventResponseProjection extends GraphQLResponseProjection {
}
def createdDateTime(alias: String): EventResponseProjection = {
- fields.add(new GraphQLResponseField("createdDateTime").alias(alias))
+ add$(new GraphQLResponseField("createdDateTime").alias(alias))
this
}
@@ -51,7 +74,7 @@ class EventResponseProjection extends GraphQLResponseProjection {
}
def assets(alias: String, subProjection: AssetResponseProjection): EventResponseProjection = {
- fields.add(new GraphQLResponseField("assets").alias(alias).projection(subProjection))
+ add$(new GraphQLResponseField("assets").alias(alias).projection(subProjection))
this
}
@@ -60,7 +83,7 @@ class EventResponseProjection extends GraphQLResponseProjection {
}
def id(alias: String): EventResponseProjection = {
- fields.add(new GraphQLResponseField("id").alias(alias))
+ add$(new GraphQLResponseField("id").alias(alias))
this
}
@@ -69,7 +92,7 @@ class EventResponseProjection extends GraphQLResponseProjection {
}
def createdBy(alias: String): EventResponseProjection = {
- fields.add(new GraphQLResponseField("createdBy").alias(alias))
+ add$(new GraphQLResponseField("createdBy").alias(alias))
this
}
@@ -78,9 +101,11 @@ class EventResponseProjection extends GraphQLResponseProjection {
}
def typename(alias: String): EventResponseProjection = {
- fields.add(new GraphQLResponseField("__typename").alias(alias))
+ add$(new GraphQLResponseField("__typename").alias(alias))
this
}
+ override def deepCopy$(): EventResponseProjection = new EventResponseProjection(this)
+
-}
+}
\ No newline at end of file
diff --git a/src/test/resources/expected-classes/scala/tostring/QueryPrivateParametrizedInput.scala.txt b/src/test/resources/expected-classes/scala/tostring/QueryPrivateParametrizedInput.scala.txt
index 4d9c1d104..ebe9915cb 100644
--- a/src/test/resources/expected-classes/scala/tostring/QueryPrivateParametrizedInput.scala.txt
+++ b/src/test/resources/expected-classes/scala/tostring/QueryPrivateParametrizedInput.scala.txt
@@ -22,6 +22,18 @@ case class QueryPrivateParametrizedInput(
createdAfter: java.time.ZonedDateTime
) extends GraphQLParametrizedInput {
+ override def deepCopy(): QueryPrivateParametrizedInput = {
+ QueryPrivateParametrizedInput(
+ this.int,
+ this.intOpt,
+ this.seq1,
+ this.seq2,
+ this.`new`,
+ this.enum,
+ this.createdAfter
+ )
+ }
+
override def toString(): String = {
scala.Seq(
"int: " + GraphQLRequestSerializer.getEntry(int),
From bea0364b2bb5746515ef3a8b85fe99faac10b5f8 Mon Sep 17 00:00:00 2001
From: Bogdan Kobylynskyi <92bogdan@gmail.com>
Date: Thu, 23 Feb 2023 10:13:12 -0500
Subject: [PATCH 08/25] New config to specify custom @Generated annotation
#1016 (#1036)
---
docs/codegen-options.md | 125 +++++++++---------
.../gradle/GraphQLCodegenGradleTask.java | 25 +++-
.../graphql/codegen/GraphQLCodegenMojo.java | 19 ++-
.../graphql/codegen/GraphQLCodegenKeys.scala | 2 +
.../codegen/GraphQLCodegenPlugin.scala | 2 +
.../graphql/codegen/GraphQLCodegen.java | 2 +-
.../codegen/model/GeneratedInformation.java | 31 +++--
.../model/GraphQLCodegenConfiguration.java | 11 ++
.../graphql/codegen/model/MappingConfig.java | 20 ++-
.../codegen/model/MappingConfigConstants.java | 17 +++
.../graphql/codegen/model/MappingContext.java | 5 +
.../GraphQLCodegenAnnotationsTest.java | 58 ++++----
.../codegen/GraphQLCodegenApisTest.java | 65 +++++----
...GraphQLCodegenCustomScalarMappingTest.java | 17 ++-
.../codegen/GraphQLCodegenDefaultsTest.java | 32 ++---
.../codegen/GraphQLCodegenEmptyTest.java | 13 +-
.../codegen/GraphQLCodegenExtendTest.java | 29 ++--
.../GraphQLCodegenFieldsResolversTest.java | 24 ++--
.../GraphQLCodegenFileCreatorTest.java | 4 +-
.../codegen/GraphQLCodegenGitHubTest.java | 20 +--
.../codegen/GraphQLCodegenImmutableTest.java | 2 +-
.../codegen/GraphQLCodegenInterfacesTest.java | 2 +-
...GraphQLCodegenIntrospectionResultTest.java | 14 +-
.../GraphQLCodegenModelsForRootTypesTest.java | 11 +-
.../codegen/GraphQLCodegenMultiFilesTest.java | 3 +-
.../codegen/GraphQLCodegenOptionalTest.java | 16 ++-
.../GraphQLCodegenParentInterfacesTest.java | 2 +-
.../codegen/GraphQLCodegenRelayTest.java | 13 +-
.../codegen/GraphQLCodegenRequestTest.java | 58 ++++----
.../codegen/GraphQLCodegenResponseTest.java | 21 +--
.../GraphQLCodegenRestrictedWordsTest.java | 2 +-
.../graphql/codegen/GraphQLCodegenTest.java | 6 +-
.../GraphQLCodegenTypesAsInterfacesTest.java | 21 +--
.../GraphQLCodegenUnionResolverTest.java | 13 +-
.../GraphQLCodegenUnionWithEnumTest.java | 2 +-
.../graphql/codegen/TestUtils.java | 7 +-
...GraphQLCodegenCustomScalarMappingTest.java | 21 +--
.../kotlin/GraphQLCodegenDeprecatedTest.java | 2 +-
.../kotlin/GraphQLCodegenEmptyTest.java | 4 +-
.../kotlin/GraphQLCodegenGitHubTest.java | 56 +++-----
...hQLCodegenInitializeNullableTypesTest.java | 2 +-
.../kotlin/GraphQLCodegenInterfacesTest.java | 2 +-
.../kotlin/GraphQLCodegenNullableTest.java | 19 ++-
.../kotlin/GraphQLCodegenOpenclassesTest.java | 2 +-
.../kotlin/GraphQLCodegenRelayTest.java | 13 +-
...nRestrictedWordsAndParameterInputTest.java | 3 +-
.../GraphQLCodegenSealedInterfacesTest.java | 2 +-
.../GraphQLCodegenTypesAsInterfacesTest.java | 17 ++-
.../GraphQLCodegenUnionResolverTest.java | 13 +-
.../GraphQLCodegenUnionWithEnumTest.java | 3 +-
.../codegen/model/MappingConfigTest.java | 5 +
.../scala/GraphQLCodegenAnnotationsTest.java | 21 +--
...GraphQLCodegenCustomScalarMappingTest.java | 16 ++-
.../scala/GraphQLCodegenDeprecatedTest.java | 2 +-
.../scala/GraphQLCodegenEmptyTest.java | 5 +-
.../scala/GraphQLCodegenExtendTest.java | 42 +++---
.../scala/GraphQLCodegenGitHubTest.java | 35 +++--
.../scala/GraphQLCodegenOpenclassesTest.java | 15 ++-
.../scala/GraphQLCodegenRelayTest.java | 13 +-
...CodegenRestrictedWordsAndToStringTest.java | 48 ++++---
.../GraphQLCodegenTypesAsInterfacesTest.java | 20 +--
.../GraphQLCodegenUnionResolverTest.java | 13 +-
62 files changed, 635 insertions(+), 473 deletions(-)
diff --git a/docs/codegen-options.md b/docs/codegen-options.md
index df36cf87d..a863c69e7 100644
--- a/docs/codegen-options.md
+++ b/docs/codegen-options.md
@@ -1,67 +1,68 @@
# Codegen Options
-| Option | Data Type | Default value | Description |
-|:-----------------------------------------------------:|:---------------------------------------------------------------------:|:------------------------------------------------------:|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
-| `graphqlSchemaPaths` | List(String) | (falls back to `graphqlSchemas`) | GraphQL schema locations. You can supply multiple paths to GraphQL schemas. To include many schemas from a folder hierarchy, use the `graphqlSchemas` block instead. |
-| `graphqlSchemas` | *See
[graphqlSchemas](#option-graphqlschemas)* | All
`.graphqls`/`.graphql`
files in
resources | Block to define the input GraphQL schemas, when exact paths are too cumbersome. See table below for a list of options. *See [graphqlSchemas](#option-graphqlschemas)* |
-| `graphqlQueryIntrospectionResu`
`ltPath` | String | None | Path to GraphQL Introspection Query result in json format (with root object `__schema` or `data.__schema`). Sample: [sample-introspection-query-result.json](../src/test/resources/introspection-result/sample-introspection-query-result.json) |
-| `outputDir` | String | None | The output target directory into which code will be generated. |
-| `configurationFiles` | List(String) | Empty | Paths to the files with mapping configurations. Supported formats. JSON, HOCON. Order of specified configuration files matters, so the default configuration should be placed at the end. |
-| `packageName` | String | Empty | Java package for generated classes. |
-| `apiPackageName` | String | Empty | Java package for generated api classes (Query, Mutation, Subscription). |
-| `modelPackageName` | String | Empty | Java package for generated model classes (type, input, interface, enum, union). |
-| `generateBuilder` | Boolean | True | Specifies whether generated model classes should have builder. |
-| `generateApis` | Boolean | True | Specifies whether api classes should be generated as well as model classes. |
-| `generateDataFetchingEnvironme`
`ntArgumentInApis` | Boolean | False | If true, then `graphql.schema.DataFetchingEnvironment env` will be added as a last argument to all methods of root type resolvers and field resolvers. |
-| `generateEqualsAndHashCode` | Boolean | False | Specifies whether generated model classes should have equals and hashCode methods defined. |
-| `generateParameterizedFieldsResolvers` | Boolean | True | Specifies whether separate `Resolver` interface for parametrized fields should be generated. If `false`, then add parametrized field to the type definition and ignore field parameters. If `true` then separate `Resolver` interface for parametrized fields will be generated. |
-| `generateImmutableModels` | Boolean | False | Specifies whether generated model classes should be immutable. |
-| `generateToString` | Boolean | False | Specifies whether generated model classes should have toString method defined. |
-| `addGeneratedAnnotation` | Boolean | True | Specifies whether generated classes should have `@Generated` annotation. |
-| `generateJacksonTypeIdResolver` | Boolean | False | Specifies whether generated union interfaces should be annotated with a custom Jackson type id resolver generated in model package. |
-| `apiNamePrefix` | String | Empty | Sets the prefix for GraphQL api classes (query, mutation, subscription). |
-| `apiNameSuffix` | String | `Resolver` | Sets the suffix for GraphQL api classes (query, mutation, subscription). |
-| `apiInterfaceStrategy` | *See
[ApiInterfaceStrategy](#option-apiinterfacestrategy)* | `INTERFACE_PER_OPERATION` | *See [ApiInterfaceStrategy](#option-apiinterfacestrategy)* |
-| `apiRootInterfaceStrategy` | *See
[ApiRootInterfaceStrategy](#option-apirootinterfacestrategy)* | `SINGLE_INTERFACE` | *See [ApiRootInterfaceStrategy](#option-apirootinterfacestrategy)* |
-| `apiNamePrefixStrategy` | *See
[ApiNamePrefixStrategy](#option-apinameprefixstrategy)* | `CONSTANT` | *See [ApiNamePrefixStrategy](#option-apinameprefixstrategy)* |
-| `modelNamePrefix` | String | Empty | Sets the prefix for GraphQL model classes (type, input, interface, enum, union). |
-| `modelNameSuffix` | String | Empty | Sets the suffix for GraphQL model classes (type, input, interface, enum, union). |
-| `modelValidationAnnotation` | String | `@javax.validation.`
`constraints.NotNull` | Annotation for mandatory (NonNull) fields. Can be null/empty. |
-| `typeResolverPrefix` | String | Empty | Sets the prefix for GraphQL type resolver classes. |
-| `typeResolverSuffix` | String | `Resolver` | Sets the suffix for GraphQL type resolver classes. |
-| `customTypesMapping` | Map(String,String) | Empty | *See [CustomTypesMapping](#option-customtypesmapping)* |
-| `customAnnotationsMapping` | Map(String,String[]) | Empty | *See [CustomAnnotationsMapping](#option-customannotationsmapping)* |
-| `directiveAnnotationsMapping` | Map(String,String[]) | Empty | *See [DirectiveAnnotationsMapping](#option-directiveannotationsmapping)* |
-| `fieldsWithResolvers` | Set(String) | Empty | Fields that require Resolvers should be defined here in format: `TypeName.fieldName` or `TypeName` or `@directive`. E.g.: `Person`, `Person.friends`, `@customResolver`. |
-| `fieldsWithoutResolvers` | Set(String) | Empty | Fields that DO NOT require Resolvers should be defined here in format: `TypeName.fieldName` or `TypeName` or `@directive`. Can be used in conjunction with `generateExtensionFieldsResolvers` option. E.g.: `Person`, `Person.friends`, `@noResolver`. |
-| `resolverArgumentAnnotations` | Set(String) | Empty | Annotations that will be added to all resolver arguments. Can be used for [spring-graphql](https://github.com/spring-projects/spring-graphql) inegration by supplying: `org.springframework.graphql.data.method.annotation.Argument` |
-| `parametrizedResolverAnnotations` | Set(String) | Empty | Annotations that will be added to all parametrized resolver methods. Can be used for [spring-graphql](https://github.com/spring-projects/spring-graphql) inegration by supplying: `org.springframework.graphql.data.method.annotation.SchemaMapping(typeName="{{TYPE_NAME}}")` |
-| `generateParameterizedFieldsR`
`esolvers` | Boolean | True | If true, then generate separate `Resolver` interface for parametrized fields. If false, then add field to the type definition and ignore field parameters. |
-| `generateExtensionFieldsResol`
`vers` | Boolean | False | Specifies whether all fields in extensions (`extend type` and `extend interface`) should be present in Resolver interface instead of the type class itself. |
-| `generateModelsForRootTypes` | Boolean | False | Specifies whether model classes should be generated for `type Query`, `type Subscription`, `type Mutation`. |
-| `useOptionalForNullableReturn`
`Types` | Boolean | False | Specifies whether nullable return types of api methods should be wrapped into [`java.util.Optional<>`](https://docs.oracle.com/javase/8/docs/api/index.html?java/util/Optional.html). Lists will not be wrapped. |
-| `generateApisWithThrowsExcept`
`ion` | Boolean | True | Specifies whether api interface methods should have `throws Exception` in signature. |
-| `apiReturnType` | String | Empty | Return type for api methods (query/mutation). For example: `reactor.core.publisher.Mono`, etc. |
-| `apiReturnListType` | String | Empty | Return type for api methods (query/mutation) having list type. For example: `reactor.core.publisher.Flux`, etc. By default is empty, so `apiReturnType` will be used. |
-| `subscriptionReturnType` | String | Empty | Return type for subscription methods. For example: `org.reactivestreams.Publisher`, `io.reactivex.Observable`, etc. |
-| `relayConfig` | *See
[RelayConfig](#option-relayconfig)* | `@connection(for: ...)` | *See [RelayConfig](#option-relayconfig)* |
-| `generateClient` | Boolean | False | Specifies whether client-side classes should be generated for each query, mutation and subscription. This includes: `Request` classes (contain input data), `ResponseProjection` classes for each type (contain response fields) and `Response` classes (contain response data). |
-| `requestSuffix` | String | Request | Sets the suffix for `Request` classes. |
-| `responseSuffix` | String | Response | Sets the suffix for `Response` classes. |
-| `responseProjectionSuffix` | String | ResponseProjection | Sets the suffix for `ResponseProjection` classes. |
-| `parametrizedInputSuffix` | String | ParametrizedInput | Sets the suffix for `ParametrizedInput` classes. |
-| `parentInterfaces` | *See
[parentInterfaces](#option-parentinterfaces)* | Empty | Block to define parent interfaces for generated interfaces (query / mutation / subscription / type resolver). *See [parentInterfaces](#option-parentinterfaces)* |
-| `generateAllMethodInProjection` | Boolean | True | Enables whether the `all$()` method should be generated in the projection classes. Disabling enforces the client to select the fields manually. |
-| `responseProjectionMaxDepth` | Integer | 3 | Sets max depth when use `all$()` which for facilitating the construction of projection automatically, the fields on all projections are provided when it be invoked. This is a global configuration, of course, you can use `all$(max)` to set for each method. For self recursive types, too big depth may result in a large number of returned data! |
-| `generatedLanguage` | Enum | GeneratedLanguage.JAVA | Choose which language you want to generate, Java,Scala,Kotlin were supported. Note that due to language features, there are slight differences in default values between languages. |
-| `generateModelOpenClasses` | Boolean | False | The class type of the generated model. If true, generate normal classes, else generate data classes. It only support in kotlin(```data class```) and scala(```case class```). Maybe we will consider to support Java ```record``` in the future. |
-| `initializeNullableTypes` | Boolean | False | Adds a default null value to nullable arguments. Only supported in Kotlin. |
-| `generateSealedInterfaces` | Boolean | False | This applies to generated interfaces on unions and interfaces. If true, generate sealed interfaces, else generate normal ones. It is only supported in Kotlin. |
-| `typesAsInterfaces` | Set(String) | Empty | Types that must generated as interfaces should be defined here in format: `TypeName` or `@directive`. E.g.: `User`, `@asInterface`. |
-| `useObjectMapperForRequestSerialization` | Set(String) | Empty | Fields that require serialization using `com.fasterxml.jackson.databind.ObjectMapper#writeValueAsString(Object)`. Values should be defined here in the following format: `GraphqlObjectName.fieldName` or `GraphqlTypeName`. If just type is specified, then all fields of this type will be serialized using ObjectMapper. E.g.: `["Person.createdDateTime", ZonedDateTime"]` |
-| `supportUnknownFields` | Boolean | False | Specifies whether api classes should support unknown fields during serialization or deserialization. If `true`, classes will include a property of type [`java.util.Map`](https://docs.oracle.com/javase/8/docs/api/index.html?java/util/Map.html) that will store unknown fields. |
-| `unknownFieldsPropertyName` | String | userDefinedFields | Specifies the name of the property to be included in api classes to support unknown fields during serialization or deserialization |
-| `skip` | Boolean | False | If true, then code generation will not happen |
+| Option | Data Type | Default value | Description |
+|:-----------------------------------------------------:|:---------------------------------------------------------------------:|:--------------------------------------------------------------:|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
+| `graphqlSchemaPaths` | List(String) | (falls back to `graphqlSchemas`) | GraphQL schema locations. You can supply multiple paths to GraphQL schemas. To include many schemas from a folder hierarchy, use the `graphqlSchemas` block instead. |
+| `graphqlSchemas` | *See
[graphqlSchemas](#option-graphqlschemas)* | All
`.graphqls`/`.graphql`
files in
resources | Block to define the input GraphQL schemas, when exact paths are too cumbersome. See table below for a list of options. *See [graphqlSchemas](#option-graphqlschemas)* |
+| `graphqlQueryIntrospectionResu`
`ltPath` | String | None | Path to GraphQL Introspection Query result in json format (with root object `__schema` or `data.__schema`). Sample: [sample-introspection-query-result.json](../src/test/resources/introspection-result/sample-introspection-query-result.json) |
+| `outputDir` | String | None | The output target directory into which code will be generated. |
+| `configurationFiles` | List(String) | Empty | Paths to the files with mapping configurations. Supported formats. JSON, HOCON. Order of specified configuration files matters, so the default configuration should be placed at the end. |
+| `packageName` | String | Empty | Java package for generated classes. |
+| `apiPackageName` | String | Empty | Java package for generated api classes (Query, Mutation, Subscription). |
+| `modelPackageName` | String | Empty | Java package for generated model classes (type, input, interface, enum, union). |
+| `generateBuilder` | Boolean | True | Specifies whether generated model classes should have builder. |
+| `generateApis` | Boolean | True | Specifies whether api classes should be generated as well as model classes. |
+| `generateDataFetchingEnvironme`
`ntArgumentInApis` | Boolean | False | If true, then `graphql.schema.DataFetchingEnvironment env` will be added as a last argument to all methods of root type resolvers and field resolvers. |
+| `generateEqualsAndHashCode` | Boolean | False | Specifies whether generated model classes should have equals and hashCode methods defined. |
+| `generateParameterizedFieldsResolvers` | Boolean | True | Specifies whether separate `Resolver` interface for parametrized fields should be generated. If `false`, then add parametrized field to the type definition and ignore field parameters. If `true` then separate `Resolver` interface for parametrized fields will be generated. |
+| `generateImmutableModels` | Boolean | False | Specifies whether generated model classes should be immutable. |
+| `generateToString` | Boolean | False | Specifies whether generated model classes should have toString method defined. |
+| `generateJacksonTypeIdResolver` | Boolean | False | Specifies whether generated union interfaces should be annotated with a custom Jackson type id resolver generated in model package. |
+| `addGeneratedAnnotation` | Boolean | True | Specifies whether generated classes should have `@Generated` annotation. |
+| `generatedAnnotation` | String | `jakarta.annotation.Generated`
`javax.annotation.Generated` | Qualified class name (with package) of the `@Generated` annotation that will be added on top of every generated class (if `addGeneratedAnnotation` is **true**) |
+| `apiNamePrefix` | String | Empty | Sets the prefix for GraphQL api classes (query, mutation, subscription). |
+| `apiNameSuffix` | String | `Resolver` | Sets the suffix for GraphQL api classes (query, mutation, subscription). |
+| `apiInterfaceStrategy` | *See
[ApiInterfaceStrategy](#option-apiinterfacestrategy)* | `INTERFACE_PER_OPERATION` | *See [ApiInterfaceStrategy](#option-apiinterfacestrategy)* |
+| `apiRootInterfaceStrategy` | *See
[ApiRootInterfaceStrategy](#option-apirootinterfacestrategy)* | `SINGLE_INTERFACE` | *See [ApiRootInterfaceStrategy](#option-apirootinterfacestrategy)* |
+| `apiNamePrefixStrategy` | *See
[ApiNamePrefixStrategy](#option-apinameprefixstrategy)* | `CONSTANT` | *See [ApiNamePrefixStrategy](#option-apinameprefixstrategy)* |
+| `modelNamePrefix` | String | Empty | Sets the prefix for GraphQL model classes (type, input, interface, enum, union). |
+| `modelNameSuffix` | String | Empty | Sets the suffix for GraphQL model classes (type, input, interface, enum, union). |
+| `modelValidationAnnotation` | String | `@javax.validation.`
`constraints.NotNull` | Annotation for mandatory (NonNull) fields. Can be null/empty. |
+| `typeResolverPrefix` | String | Empty | Sets the prefix for GraphQL type resolver classes. |
+| `typeResolverSuffix` | String | `Resolver` | Sets the suffix for GraphQL type resolver classes. |
+| `customTypesMapping` | Map(String,String) | Empty | *See [CustomTypesMapping](#option-customtypesmapping)* |
+| `customAnnotationsMapping` | Map(String,String[]) | Empty | *See [CustomAnnotationsMapping](#option-customannotationsmapping)* |
+| `directiveAnnotationsMapping` | Map(String,String[]) | Empty | *See [DirectiveAnnotationsMapping](#option-directiveannotationsmapping)* |
+| `fieldsWithResolvers` | Set(String) | Empty | Fields that require Resolvers should be defined here in format: `TypeName.fieldName` or `TypeName` or `@directive`. E.g.: `Person`, `Person.friends`, `@customResolver`. |
+| `fieldsWithoutResolvers` | Set(String) | Empty | Fields that DO NOT require Resolvers should be defined here in format: `TypeName.fieldName` or `TypeName` or `@directive`. Can be used in conjunction with `generateExtensionFieldsResolvers` option. E.g.: `Person`, `Person.friends`, `@noResolver`. |
+| `resolverArgumentAnnotations` | Set(String) | Empty | Annotations that will be added to all resolver arguments. Can be used for [spring-graphql](https://github.com/spring-projects/spring-graphql) inegration by supplying: `org.springframework.graphql.data.method.annotation.Argument` |
+| `parametrizedResolverAnnotations` | Set(String) | Empty | Annotations that will be added to all parametrized resolver methods. Can be used for [spring-graphql](https://github.com/spring-projects/spring-graphql) inegration by supplying: `org.springframework.graphql.data.method.annotation.SchemaMapping(typeName="{{TYPE_NAME}}")` |
+| `generateParameterizedFieldsR`
`esolvers` | Boolean | True | If true, then generate separate `Resolver` interface for parametrized fields. If false, then add field to the type definition and ignore field parameters. |
+| `generateExtensionFieldsResol`
`vers` | Boolean | False | Specifies whether all fields in extensions (`extend type` and `extend interface`) should be present in Resolver interface instead of the type class itself. |
+| `generateModelsForRootTypes` | Boolean | False | Specifies whether model classes should be generated for `type Query`, `type Subscription`, `type Mutation`. |
+| `useOptionalForNullableReturn`
`Types` | Boolean | False | Specifies whether nullable return types of api methods should be wrapped into [`java.util.Optional<>`](https://docs.oracle.com/javase/8/docs/api/index.html?java/util/Optional.html). Lists will not be wrapped. |
+| `generateApisWithThrowsExcept`
`ion` | Boolean | True | Specifies whether api interface methods should have `throws Exception` in signature. |
+| `apiReturnType` | String | Empty | Return type for api methods (query/mutation). For example: `reactor.core.publisher.Mono`, etc. |
+| `apiReturnListType` | String | Empty | Return type for api methods (query/mutation) having list type. For example: `reactor.core.publisher.Flux`, etc. By default is empty, so `apiReturnType` will be used. |
+| `subscriptionReturnType` | String | Empty | Return type for subscription methods. For example: `org.reactivestreams.Publisher`, `io.reactivex.Observable`, etc. |
+| `relayConfig` | *See
[RelayConfig](#option-relayconfig)* | `@connection(for: ...)` | *See [RelayConfig](#option-relayconfig)* |
+| `generateClient` | Boolean | False | Specifies whether client-side classes should be generated for each query, mutation and subscription. This includes: `Request` classes (contain input data), `ResponseProjection` classes for each type (contain response fields) and `Response` classes (contain response data). |
+| `requestSuffix` | String | Request | Sets the suffix for `Request` classes. |
+| `responseSuffix` | String | Response | Sets the suffix for `Response` classes. |
+| `responseProjectionSuffix` | String | ResponseProjection | Sets the suffix for `ResponseProjection` classes. |
+| `parametrizedInputSuffix` | String | ParametrizedInput | Sets the suffix for `ParametrizedInput` classes. |
+| `parentInterfaces` | *See
[parentInterfaces](#option-parentinterfaces)* | Empty | Block to define parent interfaces for generated interfaces (query / mutation / subscription / type resolver). *See [parentInterfaces](#option-parentinterfaces)* |
+| `generateAllMethodInProjection` | Boolean | True | Enables whether the `all$()` method should be generated in the projection classes. Disabling enforces the client to select the fields manually. |
+| `responseProjectionMaxDepth` | Integer | 3 | Sets max depth when use `all$()` which for facilitating the construction of projection automatically, the fields on all projections are provided when it be invoked. This is a global configuration, of course, you can use `all$(max)` to set for each method. For self recursive types, too big depth may result in a large number of returned data! |
+| `generatedLanguage` | Enum | GeneratedLanguage.JAVA | Choose which language you want to generate, Java,Scala,Kotlin were supported. Note that due to language features, there are slight differences in default values between languages. |
+| `generateModelOpenClasses` | Boolean | False | The class type of the generated model. If true, generate normal classes, else generate data classes. It only support in kotlin(```data class```) and scala(```case class```). Maybe we will consider to support Java ```record``` in the future. |
+| `initializeNullableTypes` | Boolean | False | Adds a default null value to nullable arguments. Only supported in Kotlin. |
+| `generateSealedInterfaces` | Boolean | False | This applies to generated interfaces on unions and interfaces. If true, generate sealed interfaces, else generate normal ones. It is only supported in Kotlin. |
+| `typesAsInterfaces` | Set(String) | Empty | Types that must generated as interfaces should be defined here in format: `TypeName` or `@directive`. E.g.: `User`, `@asInterface`. |
+| `useObjectMapperForRequestSerialization` | Set(String) | Empty | Fields that require serialization using `com.fasterxml.jackson.databind.ObjectMapper#writeValueAsString(Object)`. Values should be defined here in the following format: `GraphqlObjectName.fieldName` or `GraphqlTypeName`. If just type is specified, then all fields of this type will be serialized using ObjectMapper. E.g.: `["Person.createdDateTime", ZonedDateTime"]` |
+| `supportUnknownFields` | Boolean | False | Specifies whether api classes should support unknown fields during serialization or deserialization. If `true`, classes will include a property of type [`java.util.Map`](https://docs.oracle.com/javase/8/docs/api/index.html?java/util/Map.html) that will store unknown fields. |
+| `unknownFieldsPropertyName` | String | userDefinedFields | Specifies the name of the property to be included in api classes to support unknown fields during serialization or deserialization |
+| `skip` | Boolean | False | If true, then code generation will not happen |
### Option `graphqlSchemas`
diff --git a/plugins/gradle/graphql-java-codegen-gradle-plugin/src/main/java/io/github/kobylynskyi/graphql/codegen/gradle/GraphQLCodegenGradleTask.java b/plugins/gradle/graphql-java-codegen-gradle-plugin/src/main/java/io/github/kobylynskyi/graphql/codegen/gradle/GraphQLCodegenGradleTask.java
index e3159fd55..e63d529c0 100644
--- a/plugins/gradle/graphql-java-codegen-gradle-plugin/src/main/java/io/github/kobylynskyi/graphql/codegen/gradle/GraphQLCodegenGradleTask.java
+++ b/plugins/gradle/graphql-java-codegen-gradle-plugin/src/main/java/io/github/kobylynskyi/graphql/codegen/gradle/GraphQLCodegenGradleTask.java
@@ -82,8 +82,9 @@ public class GraphQLCodegenGradleTask extends DefaultTask implements GraphQLCode
private Boolean generateModelsForRootTypes = MappingConfigConstants.DEFAULT_GENERATE_MODELS_FOR_ROOT_TYPES;
private Boolean useOptionalForNullableReturnTypes = MappingConfigConstants.DEFAULT_USE_OPTIONAL_FOR_NULLABLE_RETURN_TYPES;
private Boolean generateApisWithThrowsException = MappingConfigConstants.DEFAULT_GENERATE_APIS_WITH_THROWS_EXCEPTION;
- private Boolean addGeneratedAnnotation = MappingConfigConstants.DEFAULT_ADD_GENERATED_ANNOTATION;
private Boolean generateJacksonTypeIdResolver = MappingConfigConstants.DEFAULT_GENERATE_JACKSON_TYPE_ID_RESOLVER;
+ private Boolean addGeneratedAnnotation = MappingConfigConstants.DEFAULT_ADD_GENERATED_ANNOTATION;
+ private String generatedAnnotation;
private Set fieldsWithResolvers = new HashSet<>();
private Set fieldsWithoutResolvers = new HashSet<>();
private Set typesAsInterfaces = new HashSet<>();
@@ -153,8 +154,9 @@ public void generate() throws Exception {
mappingConfig.setGenerateToString(generateToString);
mappingConfig.setUseOptionalForNullableReturnTypes(useOptionalForNullableReturnTypes);
mappingConfig.setGenerateApisWithThrowsException(generateApisWithThrowsException);
- mappingConfig.setAddGeneratedAnnotation(addGeneratedAnnotation);
mappingConfig.setGenerateJacksonTypeIdResolver(generateJacksonTypeIdResolver);
+ mappingConfig.setAddGeneratedAnnotation(addGeneratedAnnotation);
+ mappingConfig.setGeneratedAnnotation(generatedAnnotation);
mappingConfig.setApiReturnType(apiReturnType);
mappingConfig.setApiReturnListType(apiReturnListType);
mappingConfig.setSubscriptionReturnType(subscriptionReturnType);
@@ -647,6 +649,17 @@ public void setGenerateApisWithThrowsException(Boolean generateApisWithThrowsExc
this.generateApisWithThrowsException = generateApisWithThrowsException;
}
+ @Input
+ @Optional
+ @Override
+ public Boolean getGenerateJacksonTypeIdResolver() {
+ return generateJacksonTypeIdResolver;
+ }
+
+ public void setGenerateJacksonTypeIdResolver(Boolean generateJacksonTypeIdResolver) {
+ this.generateJacksonTypeIdResolver = generateJacksonTypeIdResolver;
+ }
+
@Input
@Optional
@Override
@@ -661,12 +674,12 @@ public void setAddGeneratedAnnotation(Boolean addGeneratedAnnotation) {
@Input
@Optional
@Override
- public Boolean getGenerateJacksonTypeIdResolver() {
- return generateJacksonTypeIdResolver;
+ public String getGeneratedAnnotation() {
+ return generatedAnnotation;
}
- public void setGenerateJacksonTypeIdResolver(Boolean generateJacksonTypeIdResolver) {
- this.generateJacksonTypeIdResolver = generateJacksonTypeIdResolver;
+ public void setGeneratedAnnotation(String generatedAnnotation) {
+ this.generatedAnnotation = generatedAnnotation;
}
@Input
diff --git a/plugins/maven/graphql-java-codegen-maven-plugin/src/main/java/io/github/kobylynskyi/graphql/codegen/GraphQLCodegenMojo.java b/plugins/maven/graphql-java-codegen-maven-plugin/src/main/java/io/github/kobylynskyi/graphql/codegen/GraphQLCodegenMojo.java
index 06ad87923..796f49099 100644
--- a/plugins/maven/graphql-java-codegen-maven-plugin/src/main/java/io/github/kobylynskyi/graphql/codegen/GraphQLCodegenMojo.java
+++ b/plugins/maven/graphql-java-codegen-maven-plugin/src/main/java/io/github/kobylynskyi/graphql/codegen/GraphQLCodegenMojo.java
@@ -149,11 +149,14 @@ public class GraphQLCodegenMojo extends AbstractMojo implements GraphQLCodegenCo
@Parameter(defaultValue = MappingConfigConstants.DEFAULT_GENERATE_APIS_WITH_THROWS_EXCEPTION_STRING)
private boolean generateApisWithThrowsException;
+ @Parameter(defaultValue = MappingConfigConstants.DEFAULT_GENERATE_JACKSON_TYPE_ID_RESOLVER_STRING)
+ private boolean generateJacksonTypeIdResolver;
+
@Parameter(defaultValue = MappingConfigConstants.DEFAULT_ADD_GENERATED_ANNOTATION_STRING)
private boolean addGeneratedAnnotation;
- @Parameter(defaultValue = MappingConfigConstants.DEFAULT_GENERATE_JACKSON_TYPE_ID_RESOLVER_STRING)
- private boolean generateJacksonTypeIdResolver;
+ @Parameter
+ private String generatedAnnotation;
@Parameter
private String[] fieldsWithResolvers;
@@ -265,8 +268,9 @@ public void execute() throws MojoExecutionException {
mappingConfig.setGenerateModelsForRootTypes(generateModelsForRootTypes);
mappingConfig.setUseOptionalForNullableReturnTypes(useOptionalForNullableReturnTypes);
mappingConfig.setGenerateApisWithThrowsException(generateApisWithThrowsException);
- mappingConfig.setAddGeneratedAnnotation(addGeneratedAnnotation);
mappingConfig.setGenerateJacksonTypeIdResolver(generateJacksonTypeIdResolver);
+ mappingConfig.setAddGeneratedAnnotation(addGeneratedAnnotation);
+ mappingConfig.setGeneratedAnnotation(generatedAnnotation);
mappingConfig.setFieldsWithResolvers(mapToHashSet(fieldsWithResolvers));
mappingConfig.setFieldsWithoutResolvers(mapToHashSet(fieldsWithoutResolvers));
mappingConfig.setRelayConfig(relayConfig);
@@ -526,14 +530,19 @@ public Boolean getGenerateApisWithThrowsException() {
return generateApisWithThrowsException;
}
+ @Override
+ public Boolean getGenerateJacksonTypeIdResolver() {
+ return generateJacksonTypeIdResolver;
+ }
+
@Override
public Boolean getAddGeneratedAnnotation() {
return addGeneratedAnnotation;
}
@Override
- public Boolean getGenerateJacksonTypeIdResolver() {
- return generateJacksonTypeIdResolver;
+ public String getGeneratedAnnotation() {
+ return generatedAnnotation;
}
@Override
diff --git a/plugins/sbt/graphql-java-codegen-sbt-plugin/src/main/scala/io/github/dreamylost/graphql/codegen/GraphQLCodegenKeys.scala b/plugins/sbt/graphql-java-codegen-sbt-plugin/src/main/scala/io/github/dreamylost/graphql/codegen/GraphQLCodegenKeys.scala
index da32112bd..c85eab40f 100644
--- a/plugins/sbt/graphql-java-codegen-sbt-plugin/src/main/scala/io/github/dreamylost/graphql/codegen/GraphQLCodegenKeys.scala
+++ b/plugins/sbt/graphql-java-codegen-sbt-plugin/src/main/scala/io/github/dreamylost/graphql/codegen/GraphQLCodegenKeys.scala
@@ -60,6 +60,8 @@ trait GraphQLCodegenKeys {
val addGeneratedAnnotation = settingKey[Boolean]("Specifies whether generated classes should be annotated with @Generated")
+ val generatedAnnotation = settingKey[Option[String]]("Qualified class name (with package) of the @Generated annotation that will be added on top of every generated class (if addGeneratedAnnotation is true)")
+
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")
diff --git a/plugins/sbt/graphql-java-codegen-sbt-plugin/src/main/scala/io/github/dreamylost/graphql/codegen/GraphQLCodegenPlugin.scala b/plugins/sbt/graphql-java-codegen-sbt-plugin/src/main/scala/io/github/dreamylost/graphql/codegen/GraphQLCodegenPlugin.scala
index 52edf7fec..e6d597a46 100644
--- a/plugins/sbt/graphql-java-codegen-sbt-plugin/src/main/scala/io/github/dreamylost/graphql/codegen/GraphQLCodegenPlugin.scala
+++ b/plugins/sbt/graphql-java-codegen-sbt-plugin/src/main/scala/io/github/dreamylost/graphql/codegen/GraphQLCodegenPlugin.scala
@@ -94,6 +94,7 @@ class GraphQLCodegenPlugin(configuration: Configuration, private[codegen] val co
useOptionalForNullableReturnTypes := MappingConfigConstants.DEFAULT_USE_OPTIONAL_FOR_NULLABLE_RETURN_TYPES,
generateApisWithThrowsException := MappingConfigConstants.DEFAULT_GENERATE_APIS_WITH_THROWS_EXCEPTION,
addGeneratedAnnotation := MappingConfigConstants.DEFAULT_ADD_GENERATED_ANNOTATION,
+ generatedAnnotation := None,
typesAsInterfaces := new JHashSet[String](),
relayConfig := defaultRelayConfig,
// package name configs:
@@ -171,6 +172,7 @@ class GraphQLCodegenPlugin(configuration: Configuration, private[codegen] val co
mappingConfig.setUseOptionalForNullableReturnTypes((useOptionalForNullableReturnTypes in GraphQLCodegenConfig).value)
mappingConfig.setGenerateApisWithThrowsException((generateApisWithThrowsException in GraphQLCodegenConfig).value)
mappingConfig.setAddGeneratedAnnotation((addGeneratedAnnotation in GraphQLCodegenConfig).value)
+ mappingConfig.setGeneratedAnnotation((generatedAnnotation in GraphQLCodegenConfig).value.orNull)
mappingConfig.setGenerateAllMethodInProjection((generateAllMethodInProjection in GraphQLCodegenConfig).value)
mappingConfig.setResponseProjectionMaxDepth((responseProjectionMaxDepth in GraphQLCodegenConfig).value)
mappingConfig.setRelayConfig((relayConfig in GraphQLCodegenConfig).value)
diff --git a/src/main/java/com/kobylynskyi/graphql/codegen/GraphQLCodegen.java b/src/main/java/com/kobylynskyi/graphql/codegen/GraphQLCodegen.java
index 2a59423e3..dcdd43606 100644
--- a/src/main/java/com/kobylynskyi/graphql/codegen/GraphQLCodegen.java
+++ b/src/main/java/com/kobylynskyi/graphql/codegen/GraphQLCodegen.java
@@ -69,7 +69,7 @@ protected GraphQLCodegen(List schemas,
MappingConfigSupplier externalMappingConfigSupplier,
MapperFactory mapperFactory) {
this(schemas, introspectionResult, outputDir, mappingConfig, externalMappingConfigSupplier,
- new GeneratedInformation(), mapperFactory);
+ new GeneratedInformation(mappingConfig), mapperFactory);
}
// used by other constructors
diff --git a/src/main/java/com/kobylynskyi/graphql/codegen/model/GeneratedInformation.java b/src/main/java/com/kobylynskyi/graphql/codegen/model/GeneratedInformation.java
index b47024c09..79ff2f93f 100644
--- a/src/main/java/com/kobylynskyi/graphql/codegen/model/GeneratedInformation.java
+++ b/src/main/java/com/kobylynskyi/graphql/codegen/model/GeneratedInformation.java
@@ -10,26 +10,37 @@
public class GeneratedInformation {
public static final DateTimeFormatter DATE_TIME_FORMAT = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssZ");
+
private final String generatedType;
private Supplier dateTimeSupplier;
- public GeneratedInformation() {
- this(ZonedDateTime::now);
+ public GeneratedInformation(MappingConfig mappingConfig) {
+ this(ZonedDateTime::now, mappingConfig);
}
- public GeneratedInformation(Supplier dateTimeSupplier) {
+ public GeneratedInformation(Supplier dateTimeSupplier, MappingConfig mappingConfig) {
this.dateTimeSupplier = dateTimeSupplier;
- this.generatedType = initGeneratedType();
+ this.generatedType = initGeneratedType(mappingConfig);
}
- private static String initGeneratedType() {
+ private static String initGeneratedType(MappingConfig mappingConfig) {
+ if (mappingConfig != null &&
+ mappingConfig.getGeneratedAnnotation() != null &&
+ !mappingConfig.getGeneratedAnnotation().isEmpty()) {
+ return mappingConfig.getGeneratedAnnotation();
+ }
+ // default logic if mapping config doesn't have a specific annotation
try {
- return Class.forName("javax.annotation.processing.Generated").getCanonicalName();
- } catch (ClassNotFoundException ignored1) {
+ return Class.forName("jakarta.annotation.Generated").getCanonicalName();
+ } catch (ClassNotFoundException ignored0) {
try {
- return Class.forName("javax.annotation.Generated").getCanonicalName();
- } catch (ClassNotFoundException ignored2) {
- // class is not available
+ return Class.forName("javax.annotation.processing.Generated").getCanonicalName();
+ } catch (ClassNotFoundException ignored1) {
+ try {
+ return Class.forName("javax.annotation.Generated").getCanonicalName();
+ } catch (ClassNotFoundException ignored2) {
+ // class is not available
+ }
}
}
return null;
diff --git a/src/main/java/com/kobylynskyi/graphql/codegen/model/GraphQLCodegenConfiguration.java b/src/main/java/com/kobylynskyi/graphql/codegen/model/GraphQLCodegenConfiguration.java
index fd6d74cdf..e44ca1529 100644
--- a/src/main/java/com/kobylynskyi/graphql/codegen/model/GraphQLCodegenConfiguration.java
+++ b/src/main/java/com/kobylynskyi/graphql/codegen/model/GraphQLCodegenConfiguration.java
@@ -502,5 +502,16 @@ public interface GraphQLCodegenConfiguration {
*/
String getUnknownFieldsPropertyName();
+ /**
+ * Returns a qualified class name (with package) of the Generated annotation that will be added on top of every
+ * generated class.
+ *
+ * @return The name of the class for @Generated annotation
+ * @see "jakarta.annotation.Generated"
+ * @see "javax.annotation.processing.Generated"
+ * @see "javax.annotation.Generated"
+ */
+ String getGeneratedAnnotation();
+
}
diff --git a/src/main/java/com/kobylynskyi/graphql/codegen/model/MappingConfig.java b/src/main/java/com/kobylynskyi/graphql/codegen/model/MappingConfig.java
index de814f805..c5a503d8e 100644
--- a/src/main/java/com/kobylynskyi/graphql/codegen/model/MappingConfig.java
+++ b/src/main/java/com/kobylynskyi/graphql/codegen/model/MappingConfig.java
@@ -20,7 +20,7 @@ public class MappingConfig implements GraphQLCodegenConfiguration, Combinable T getValueOrDefaultToThis(MappingConfig source, Function getValueFunction) {
@@ -689,6 +694,15 @@ public void setUnknownFieldsPropertyName(String unknownFieldsPropertyName) {
this.unknownFieldsPropertyName = unknownFieldsPropertyName;
}
+ @Override
+ public String getGeneratedAnnotation() {
+ return generatedAnnotation;
+ }
+
+ public void setGeneratedAnnotation(String generatedAnnotation) {
+ this.generatedAnnotation = generatedAnnotation;
+ }
+
@Override
public Boolean isSupportUnknownFields() {
return supportUnknownFields;
diff --git a/src/main/java/com/kobylynskyi/graphql/codegen/model/MappingConfigConstants.java b/src/main/java/com/kobylynskyi/graphql/codegen/model/MappingConfigConstants.java
index 8bd113789..62bcfe1ca 100644
--- a/src/main/java/com/kobylynskyi/graphql/codegen/model/MappingConfigConstants.java
+++ b/src/main/java/com/kobylynskyi/graphql/codegen/model/MappingConfigConstants.java
@@ -9,40 +9,57 @@ public class MappingConfigConstants {
public static final String DEFAULT_VALIDATION_ANNOTATION = "javax.validation.constraints.NotNull";
public static final String PARENT_INTERFACE_TYPE_PLACEHOLDER = "{{TYPE}}";
public static final String TYPE_NAME_PLACEHOLDER = "{{TYPE_NAME}}";
+
public static final boolean DEFAULT_GENERATE_APIS = true;
public static final String DEFAULT_GENERATE_APIS_STRING = "true";
+
public static final boolean DEFAULT_BUILDER = true;
public static final String DEFAULT_BUILDER_STRING = "true";
+
public static final boolean DEFAULT_EQUALS_AND_HASHCODE = false;
public static final String DEFAULT_EQUALS_AND_HASHCODE_STRING = "false";
+
public static final boolean DEFAULT_GENERATE_IMMUTABLE_MODELS = false;
public static final String DEFAULT_GENERATE_IMMUTABLE_MODELS_STRING = "false";
+
public static final boolean DEFAULT_TO_STRING = false;
public static final String DEFAULT_TO_STRING_STRING = "false";
+
public static final boolean DEFAULT_GENERATE_PARAMETERIZED_FIELDS_RESOLVERS = true;
public static final String DEFAULT_GENERATE_PARAMETERIZED_FIELDS_RESOLVERS_STRING = "true";
+
public static final boolean DEFAULT_GENERATE_EXTENSION_FIELDS_RESOLVERS = false;
public static final String DEFAULT_GENERATE_EXTENSION_FIELDS_RESOLVERS_STRING = "false";
+
public static final boolean DEFAULT_GENERATE_DATA_FETCHING_ENV = false;
public static final String DEFAULT_GENERATE_DATA_FETCHING_ENV_STRING = "false";
+
public static final boolean DEFAULT_GENERATE_MODELS_FOR_ROOT_TYPES = false;
public static final String DEFAULT_GENERATE_MODELS_FOR_ROOT_TYPES_STRING = "false";
+
public static final boolean DEFAULT_GENERATE_APIS_WITH_THROWS_EXCEPTION = true;
public static final String DEFAULT_GENERATE_APIS_WITH_THROWS_EXCEPTION_STRING = "true";
+
public static final boolean DEFAULT_ADD_GENERATED_ANNOTATION = true;
public static final String DEFAULT_ADD_GENERATED_ANNOTATION_STRING = "true";
+
public static final boolean DEFAULT_GENERATE_JACKSON_TYPE_ID_RESOLVER = false;
public static final String DEFAULT_GENERATE_JACKSON_TYPE_ID_RESOLVER_STRING = "false";
+
public static final boolean DEFAULT_USE_OPTIONAL_FOR_NULLABLE_RETURN_TYPES = false;
public static final String DEFAULT_USE_OPTIONAL_FOR_NULLABLE_RETURN_TYPES_STRING = "false";
+
public static final ApiNamePrefixStrategy DEFAULT_API_NAME_PREFIX_STRATEGY = ApiNamePrefixStrategy.CONSTANT;
public static final String DEFAULT_API_NAME_PREFIX_STRATEGY_STRING = "CONSTANT";
+
public static final ApiRootInterfaceStrategy DEFAULT_API_ROOT_INTERFACE_STRATEGY =
ApiRootInterfaceStrategy.SINGLE_INTERFACE;
public static final String DEFAULT_API_ROOT_INTERFACE_STRATEGY_STRING = "SINGLE_INTERFACE";
+
public static final ApiInterfaceStrategy DEFAULT_API_INTERFACE_STRATEGY =
ApiInterfaceStrategy.INTERFACE_PER_OPERATION;
public static final String DEFAULT_API_INTERFACE_STRATEGY_STRING = "INTERFACE_PER_OPERATION";
+
public static final boolean DEFAULT_GENERATE_CLIENT = false;
public static final String DEFAULT_GENERATE_CLIENT_STRING = "false";
diff --git a/src/main/java/com/kobylynskyi/graphql/codegen/model/MappingContext.java b/src/main/java/com/kobylynskyi/graphql/codegen/model/MappingContext.java
index 557e73d6e..479591039 100644
--- a/src/main/java/com/kobylynskyi/graphql/codegen/model/MappingContext.java
+++ b/src/main/java/com/kobylynskyi/graphql/codegen/model/MappingContext.java
@@ -336,6 +336,11 @@ public String getUnknownFieldsPropertyName() {
return config.getUnknownFieldsPropertyName();
}
+ @Override
+ public String getGeneratedAnnotation() {
+ return config.getGeneratedAnnotation();
+ }
+
public ExtendedDocument getDocument() {
return document;
}
diff --git a/src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenAnnotationsTest.java b/src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenAnnotationsTest.java
index 66cc42fcf..811224722 100644
--- a/src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenAnnotationsTest.java
+++ b/src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenAnnotationsTest.java
@@ -8,6 +8,7 @@
import org.junit.jupiter.api.Test;
import java.io.File;
+import java.io.IOException;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
@@ -48,8 +49,7 @@ void generate_CustomAnnotationMappings() throws Exception {
singletonList("@com.fasterxml.jackson.databind.annotation.JsonDeserialize(" +
"using = com.example.json.DateTimeScalarDeserializer.class)"))));
- new JavaGraphQLCodegen(singletonList("src/test/resources/schemas/test.graphqls"),
- outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo()).generate();
+ generate("src/test/resources/schemas/test.graphqls");
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
assertFileContainsElements(files, "Event.java",
@@ -65,8 +65,7 @@ void generate_CustomAnnotationMappings_Type() throws Exception {
singletonList("com.fasterxml.jackson.databind.annotation.JsonDeserialize(" +
"using = com.example.json.DateTimeScalarDeserializer.class)"))));
- new JavaGraphQLCodegen(singletonList("src/test/resources/schemas/test.graphqls"),
- outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo()).generate();
+ generate("src/test/resources/schemas/test.graphqls");
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
assertFileContainsElements(files, "Event.java",
@@ -82,8 +81,7 @@ void generate_CustomAnnotationMappings_Regexp() throws Exception {
singletonList("com.fasterxml.jackson.databind.annotation.JsonDeserialize(" +
"using = com.example.json.DateTimeScalarDeserializer.class)"))));
- new JavaGraphQLCodegen(singletonList("src/test/resources/schemas/test.graphqls"),
- outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo()).generate();
+ generate("src/test/resources/schemas/test.graphqls");
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
assertFileContainsElements(files, "Event.java",
@@ -99,8 +97,7 @@ void generate_CustomAnnotationMappings_FieldType() throws Exception {
singletonList("@com.fasterxml.jackson.databind.annotation.JsonDeserialize(" +
"using = com.example.json.DateTimeScalarDeserializer.class)"))));
- new JavaGraphQLCodegen(singletonList("src/test/resources/schemas/test.graphqls"),
- outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo()).generate();
+ generate("src/test/resources/schemas/test.graphqls");
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
assertFileContainsElements(files, "Event.java",
@@ -116,8 +113,7 @@ void generate_CustomAnnotationMappings_FieldType_Regexp() throws Exception {
singletonList("@com.fasterxml.jackson.databind.annotation.JsonDeserialize(" +
"using = com.example.json.DateTimeScalarDeserializer.class)"))));
- new JavaGraphQLCodegen(singletonList("src/test/resources/schemas/test.graphqls"),
- outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo()).generate();
+ generate("src/test/resources/schemas/test.graphqls");
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
assertFileContainsElements(files, "Event.java",
@@ -151,8 +147,7 @@ void generate_CustomAnnotationMappings_Class() throws Exception {
"using = DeploymentOrderFieldDeserializer.class)"));
mappingConfig.setCustomAnnotationsMapping(customAnnotationsMapping);
- new JavaGraphQLCodegen(singletonList("src/test/resources/schemas/github.graphqls"),
- outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo()).generate();
+ generate("src/test/resources/schemas/github.graphqls");
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
assertFileContainsElements(files, "AcceptTopicSuggestionInput.java",
@@ -189,8 +184,7 @@ void generate_CustomAnnotationMappings_Multiple() throws Exception {
"AcceptTopicSuggestionPayloadTypeResolver.class)"));
mappingConfig.setCustomAnnotationsMapping(customAnnotationsMapping);
- new JavaGraphQLCodegen(singletonList("src/test/resources/schemas/github.graphqls"),
- outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo()).generate();
+ generate("src/test/resources/schemas/github.graphqls");
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
assertFileContainsElements(files, "AcceptTopicSuggestionPayload.java", System.lineSeparator() +
@@ -209,8 +203,7 @@ void generate_ResolverArgumentAnnotations() throws Exception {
mappingConfig.setResolverArgumentAnnotations(singleton(
"@org.springframework.graphql.data.method.annotation.Argument"));
- new JavaGraphQLCodegen(singletonList("src/test/resources/schemas/test.graphqls"),
- outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo()).generate();
+ generate("src/test/resources/schemas/test.graphqls");
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
assertSameTrimmedContent(new File("src/test/resources/expected-classes/annotation/" +
@@ -228,8 +221,7 @@ void generate_ParametrizedResolverAnnotations() throws Exception {
mappingConfig.setParametrizedResolverAnnotations(singleton(
"@org.springframework.graphql.data.method.annotation.SchemaMapping(typeName=\"{{TYPE_NAME}}\")"));
- new JavaGraphQLCodegen(singletonList("src/test/resources/schemas/test.graphqls"),
- outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo()).generate();
+ generate("src/test/resources/schemas/test.graphqls");
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
assertSameTrimmedContent(new File("src/test/resources/expected-classes/annotation/" +
@@ -251,8 +243,7 @@ void generate_CustomAnnotationMappings_RequestResponseClasses() throws Exception
mappingConfig.setCustomAnnotationsMapping(customAnnotationsMapping);
mappingConfig.setGenerateClient(true);
- new JavaGraphQLCodegen(singletonList("src/test/resources/schemas/github.graphqls"),
- outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo()).generate();
+ generate("src/test/resources/schemas/github.graphqls");
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
assertFileContainsElements(files, "CodeOfConductQueryRequest.java",
@@ -283,8 +274,7 @@ void generate_Directives() throws Exception {
singletonList("@com.example.Relationship(type = {{type}}, direction = {{direction}})"));
mappingConfig.setDirectiveAnnotationsMapping(directiveAnnotationsMapping);
- new JavaGraphQLCodegen(singletonList("src/test/resources/schemas/test.graphqls"),
- outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo()).generate();
+ generate("src/test/resources/schemas/test.graphqls");
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
assertSameTrimmedContent(
@@ -303,9 +293,7 @@ void generate_Directives() throws Exception {
@Test
void generate_ModelValidationAnnotationForSubType() throws Exception {
- new JavaGraphQLCodegen(singletonList(
- "src/test/resources/schemas/nullable-list-type-with-nullable-sub-types.graphqls"),
- outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo()).generate();
+ generate("src/test/resources/schemas/nullable-list-type-with-nullable-sub-types.graphqls");
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
assertSameTrimmedContent(
@@ -317,4 +305,24 @@ void generate_ModelValidationAnnotationForSubType() throws Exception {
getFileByName(files, "TypeWithNullableListType.java"));
}
+ @Test
+ void generate_GeneratedAnnotation() throws Exception {
+ mappingConfig.setGeneratedAnnotation("jakarta.annotation.Generated");
+
+ generate("src/test/resources/schemas/test.graphqls");
+
+ File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
+ assertFileContainsElements(files, "Event.java", " */" + System.lineSeparator() +
+ "@jakarta.annotation.Generated(" + System.lineSeparator() +
+ " value = \"com.kobylynskyi.graphql.codegen.GraphQLCodegen\"," + System.lineSeparator() +
+ " date = \"2020-12-31T23:59:59-0500\"" + System.lineSeparator() +
+ ")" + System.lineSeparator() +
+ "public class Event implements java.io.Serializable {");
+ }
+
+ private void generate(String path) throws IOException {
+ new JavaGraphQLCodegen(singletonList(path), outputBuildDir, mappingConfig,
+ TestUtils.getStaticGeneratedInfo(mappingConfig)).generate();
+ }
+
}
diff --git a/src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenApisTest.java b/src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenApisTest.java
index aa4f2186b..c4c05a316 100644
--- a/src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenApisTest.java
+++ b/src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenApisTest.java
@@ -9,7 +9,6 @@
import com.kobylynskyi.graphql.codegen.supplier.SchemaFinder;
import com.kobylynskyi.graphql.codegen.utils.Utils;
import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import java.io.File;
@@ -27,6 +26,7 @@
import static java.util.stream.Collectors.toList;
import static java.util.stream.Collectors.toSet;
import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
class GraphQLCodegenApisTest {
@@ -44,9 +44,8 @@ void cleanup() {
void generate_FileNameAsPrefix() throws Exception {
schemaFinder.setIncludePattern("sub-schema.*\\.graphqls");
mappingConfig.setApiNamePrefixStrategy(ApiNamePrefixStrategy.FILE_NAME_AS_PREFIX);
- new JavaGraphQLCodegen(schemaFinder.findSchemas(), outputBuildDir, mappingConfig,
- TestUtils.getStaticGeneratedInfo())
- .generate();
+
+ generate();
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
Set generatedFileNames = Arrays.stream(files).map(File::getName).collect(toSet());
@@ -58,9 +57,8 @@ void generate_FileNameAsPrefix() throws Exception {
void generate_FolderNameAsPrefix() throws Exception {
schemaFinder.setIncludePattern("sub-schema.*\\.graphqls");
mappingConfig.setApiNamePrefixStrategy(ApiNamePrefixStrategy.FOLDER_NAME_AS_PREFIX);
- new JavaGraphQLCodegen(schemaFinder.findSchemas(), outputBuildDir, mappingConfig,
- TestUtils.getStaticGeneratedInfo())
- .generate();
+
+ generate();
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
Set generatedFileNames = Arrays.stream(files).map(File::getName).collect(toSet());
@@ -72,9 +70,8 @@ void generate_FolderNameAsPrefix() throws Exception {
void generate_Constant() throws Exception {
schemaFinder.setIncludePattern("sub-schema.*\\.graphqls");
mappingConfig.setApiNamePrefixStrategy(ApiNamePrefixStrategy.CONSTANT);
- new JavaGraphQLCodegen(schemaFinder.findSchemas(), outputBuildDir, mappingConfig,
- TestUtils.getStaticGeneratedInfo())
- .generate();
+
+ generate();
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
Set generatedFileNames = Arrays.stream(files).map(File::getName).collect(toSet());
@@ -87,14 +84,13 @@ void generate_InterfacePerSchemaAndFolderNameAsPrefix() throws Exception {
schemaFinder.setIncludePattern("sub-schema.*\\.graphqls");
mappingConfig.setApiNamePrefixStrategy(ApiNamePrefixStrategy.FOLDER_NAME_AS_PREFIX);
mappingConfig.setApiRootInterfaceStrategy(ApiRootInterfaceStrategy.INTERFACE_PER_SCHEMA);
- new JavaGraphQLCodegen(schemaFinder.findSchemas(), outputBuildDir, mappingConfig,
- TestUtils.getStaticGeneratedInfo())
- .generate();
+
+ generate();
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
Set generatedFileNames = Arrays.stream(files).map(File::getName).collect(toSet());
assertEquals(new HashSet<>(asList("SubProj1PingQueryResolver.java", "SubProj2PongQueryResolver.java",
- "SubProj1QueryResolver.java", "SubProj2QueryResolver.java")),
+ "SubProj1QueryResolver.java", "SubProj2QueryResolver.java")),
generatedFileNames);
}
@@ -103,14 +99,13 @@ void generate_InterfacePerSchemaAndFileNameAsPrefix() throws Exception {
schemaFinder.setIncludePattern("sub-schema.*\\.graphqls");
mappingConfig.setApiNamePrefixStrategy(ApiNamePrefixStrategy.FILE_NAME_AS_PREFIX);
mappingConfig.setApiRootInterfaceStrategy(ApiRootInterfaceStrategy.INTERFACE_PER_SCHEMA);
- new JavaGraphQLCodegen(schemaFinder.findSchemas(), outputBuildDir, mappingConfig,
- TestUtils.getStaticGeneratedInfo())
- .generate();
+
+ generate();
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
Set generatedFileNames = Arrays.stream(files).map(File::getName).collect(toSet());
assertEquals(new HashSet<>(asList("SubSchema1PingQueryResolver.java", "SubSchema2PongQueryResolver.java",
- "SubSchema1QueryResolver.java", "SubSchema2QueryResolver.java")),
+ "SubSchema1QueryResolver.java", "SubSchema2QueryResolver.java")),
generatedFileNames);
}
@@ -119,9 +114,9 @@ void generate_InterfacePerSchemaAndConstantPrefix() throws IOException {
schemaFinder.setIncludePattern("sub-schema.*\\.graphqls");
mappingConfig.setApiNamePrefixStrategy(ApiNamePrefixStrategy.CONSTANT);
mappingConfig.setApiRootInterfaceStrategy(ApiRootInterfaceStrategy.INTERFACE_PER_SCHEMA);
- GeneratedInformation generatedInformation = TestUtils.getStaticGeneratedInfo();
+ GeneratedInformation generatedInformation = TestUtils.getStaticGeneratedInfo(mappingConfig);
List schemas = schemaFinder.findSchemas();
- Assertions.assertThrows(IllegalArgumentException.class,
+ assertThrows(IllegalArgumentException.class,
() -> new JavaGraphQLCodegen(schemas, outputBuildDir, mappingConfig,
generatedInformation));
}
@@ -131,14 +126,12 @@ void generate_DoNotGenerateApiInterfaceForOperations() throws IOException {
schemaFinder.setIncludePattern("test.*\\.graphqls");
mappingConfig.setApiInterfaceStrategy(ApiInterfaceStrategy.DO_NOT_GENERATE);
- new JavaGraphQLCodegen(schemaFinder.findSchemas(), outputBuildDir, mappingConfig,
- TestUtils.getStaticGeneratedInfo())
- .generate();
+ generate();
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
assertEquals(Arrays.asList(
- "Event.java", "EventProperty.java", "EventPropertyResolver.java", "EventStatus.java",
- "MutationResolver.java", "QueryResolver.java", "SubscriptionResolver.java", "User.java"),
+ "Event.java", "EventProperty.java", "EventPropertyResolver.java", "EventStatus.java",
+ "MutationResolver.java", "QueryResolver.java", "SubscriptionResolver.java", "User.java"),
Arrays.stream(files).map(File::getName).sorted().collect(toList()));
}
@@ -147,16 +140,14 @@ void generate_DoNotGenerateRootApiInterfaces() throws IOException {
schemaFinder.setIncludePattern("test.*\\.graphqls");
mappingConfig.setApiRootInterfaceStrategy(ApiRootInterfaceStrategy.DO_NOT_GENERATE);
- new JavaGraphQLCodegen(schemaFinder.findSchemas(), outputBuildDir, mappingConfig,
- TestUtils.getStaticGeneratedInfo())
- .generate();
+ generate();
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
assertEquals(Arrays.asList(
- "CreateEventMutationResolver.java", "Event.java", "EventByIdQueryResolver.java", "EventProperty.java",
- "EventPropertyResolver.java", "EventStatus.java", "EventsByCategoryAndStatusQueryResolver.java",
- "EventsByIdsQueryResolver.java", "EventsCreatedSubscriptionResolver.java", "User.java",
- "VersionQueryResolver.java"),
+ "CreateEventMutationResolver.java", "Event.java", "EventByIdQueryResolver.java",
+ "EventProperty.java", "EventPropertyResolver.java", "EventStatus.java",
+ "EventsByCategoryAndStatusQueryResolver.java", "EventsByIdsQueryResolver.java",
+ "EventsCreatedSubscriptionResolver.java", "User.java", "VersionQueryResolver.java"),
Arrays.stream(files).map(File::getName).sorted().collect(toList()));
}
@@ -165,9 +156,7 @@ void generate_WithoutThrowsException() throws IOException {
schemaFinder.setIncludePattern("github.*\\.graphqls");
mappingConfig.setGenerateApisWithThrowsException(false);
- new JavaGraphQLCodegen(schemaFinder.findSchemas(), outputBuildDir, mappingConfig,
- TestUtils.getStaticGeneratedInfo())
- .generate();
+ generate();
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
@@ -179,4 +168,10 @@ void generate_WithoutThrowsException() throws IOException {
getFileByName(files, "MutationResolver.java"));
}
+ private void generate() throws IOException {
+ new JavaGraphQLCodegen(schemaFinder.findSchemas(), outputBuildDir, mappingConfig,
+ TestUtils.getStaticGeneratedInfo(mappingConfig))
+ .generate();
+ }
+
}
\ No newline at end of file
diff --git a/src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenCustomScalarMappingTest.java b/src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenCustomScalarMappingTest.java
index 834673869..9a6654278 100644
--- a/src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenCustomScalarMappingTest.java
+++ b/src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenCustomScalarMappingTest.java
@@ -8,6 +8,7 @@
import org.junit.jupiter.api.Test;
import java.io.File;
+import java.io.IOException;
import java.util.HashMap;
import java.util.Objects;
@@ -28,7 +29,6 @@ void init() {
mappingConfig = new MappingConfig();
mappingConfig.setPackageName("com.kobylynskyi.graphql.test1");
mappingConfig.setGenerateClient(true);
-
}
@AfterEach
@@ -40,8 +40,7 @@ void cleanup() {
void generate_CustomTypeMapping_WholeScalar() throws Exception {
mappingConfig.setCustomTypesMapping(new HashMap<>(singletonMap("ZonedDateTime", "String")));
- new JavaGraphQLCodegen(singletonList("src/test/resources/schemas/date-scalar.graphqls"),
- outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo()).generate();
+ generate("src/test/resources/schemas/date-scalar.graphqls");
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
@@ -57,8 +56,7 @@ void generate_CustomTypeMapping_ScalarOnQueryOnly() throws Exception {
customTypesMapping.put("ZonedDateTime", "java.time.ZonedDateTime");
mappingConfig.setCustomTypesMapping(customTypesMapping);
- new JavaGraphQLCodegen(singletonList("src/test/resources/schemas/date-scalar.graphqls"),
- outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo()).generate();
+ generate("src/test/resources/schemas/date-scalar.graphqls");
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
@@ -79,8 +77,7 @@ void generate_CustomTypeMapping_ForExtensionProperty() throws Exception {
mappingConfig.setCustomTypesMapping(new HashMap<>(singletonMap("External", "com.example.External")));
mappingConfig.setGenerateClient(false);
- new JavaGraphQLCodegen(singletonList("src/test/resources/schemas/external-type-extend.graphqls"),
- outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo()).generate();
+ generate("src/test/resources/schemas/external-type-extend.graphqls");
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
@@ -89,4 +86,10 @@ void generate_CustomTypeMapping_ForExtensionProperty() throws Exception {
getFileByName(files, "ExternalResolver.java"));
}
+ private void generate(String path) throws IOException {
+ new JavaGraphQLCodegen(singletonList(path),
+ outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo(mappingConfig))
+ .generate();
+ }
+
}
diff --git a/src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenDefaultsTest.java b/src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenDefaultsTest.java
index 900e8aad4..fac00d6c8 100644
--- a/src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenDefaultsTest.java
+++ b/src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenDefaultsTest.java
@@ -8,6 +8,7 @@
import org.junit.jupiter.api.Test;
import java.io.File;
+import java.io.IOException;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
@@ -39,8 +40,7 @@ void cleanup() {
@Test
void generate_CheckFiles() throws Exception {
- new JavaGraphQLCodegen(singletonList("src/test/resources/schemas/defaults.graphqls"),
- outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo()).generate();
+ generate("src/test/resources/schemas/defaults.graphqls");
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
List generatedFileNames = Arrays.stream(files).map(File::getName).sorted().collect(toList());
@@ -48,8 +48,7 @@ void generate_CheckFiles() throws Exception {
for (File file : files) {
assertSameTrimmedContent(new File(String.format("src/test/resources/expected-classes/defaults/%s.txt",
- file.getName())),
- file);
+ file.getName())), file);
}
}
@@ -58,8 +57,7 @@ void generate_UnkonwnFields() throws Exception {
mappingConfig.setSupportUnknownFields(true);
mappingConfig.setUnknownFieldsPropertyName("userDefinedFields");
- new JavaGraphQLCodegen(singletonList("src/test/resources/schemas/defaults.graphqls"),
- outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo()).generate();
+ generate("src/test/resources/schemas/defaults.graphqls");
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
List generatedFileNames = Arrays.stream(files).map(File::getName).sorted().collect(toList());
@@ -67,8 +65,7 @@ void generate_UnkonwnFields() throws Exception {
for (File file : files) {
assertSameTrimmedContent(new File(String.format("src/test/resources/expected-classes/unknown-fields/%s.txt",
- file.getName())),
- file);
+ file.getName())), file);
}
}
@@ -76,8 +73,7 @@ void generate_UnkonwnFields() throws Exception {
void generate_CheckFiles_WithPrefixSuffix() throws Exception {
mappingConfig.setModelNameSuffix("TO");
- new JavaGraphQLCodegen(singletonList("src/test/resources/schemas/defaults.graphqls"),
- outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo()).generate();
+ generate("src/test/resources/schemas/defaults.graphqls");
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
List generatedFileNames = Arrays.stream(files).map(File::getName).sorted().collect(toList());
@@ -85,8 +81,7 @@ void generate_CheckFiles_WithPrefixSuffix() throws Exception {
for (File file : files) {
assertSameTrimmedContent(new File(String.format("src/test/resources/expected-classes/defaults/%s.txt",
- file.getName())),
- file);
+ file.getName())), file);
}
}
@@ -94,16 +89,21 @@ void generate_CheckFiles_WithPrefixSuffix() throws Exception {
void generate_CheckFiles_OnLongDefault() throws Exception {
mappingConfig.setCustomTypesMapping(new HashMap<>(singletonMap("Long", "java.lang.Long")));
mappingConfig.setModelNameSuffix("DTO");
- new JavaGraphQLCodegen(singletonList("src/test/resources/schemas/defaults-with-Long.graphqls"),
- outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo()).generate();
+
+ generate("src/test/resources/schemas/defaults-with-Long.graphqls");
+
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
List generatedFileNames = Arrays.stream(files).map(File::getName).sorted().collect(toList());
assertEquals(asList("InputWithDefaultsDTO.java", "MyEnumDTO.java", "SomeObjectDTO.java"), generatedFileNames);
for (File file : files) {
assertSameTrimmedContent(new File(String.format("src/test/resources/expected-classes/defaults/%s.txt",
- file.getName())),
- file);
+ file.getName())), file);
}
}
+
+ private void generate(String path) throws IOException {
+ new JavaGraphQLCodegen(singletonList(path),
+ outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo(mappingConfig)).generate();
+ }
}
diff --git a/src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenEmptyTest.java b/src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenEmptyTest.java
index 02866ace9..26f1eb0a3 100644
--- a/src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenEmptyTest.java
+++ b/src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenEmptyTest.java
@@ -9,6 +9,7 @@
import org.junit.jupiter.api.Test;
import java.io.File;
+import java.io.IOException;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.HashSet;
@@ -40,8 +41,7 @@ void cleanup() {
@Test
void generateServerSideClasses() throws Exception {
- new JavaGraphQLCodegen(schemaFinder.findSchemas(), outputBuildDir, mappingConfig,
- TestUtils.getStaticGeneratedInfo()).generate();
+ generate();
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
Set generatedFileNames = Arrays.stream(files).map(File::getName).collect(toSet());
@@ -60,8 +60,8 @@ void generateServerSideClasses() throws Exception {
void generateClientSideClasses() throws Exception {
mappingConfig.setGenerateApis(false);
mappingConfig.setGenerateClient(true);
- new JavaGraphQLCodegen(schemaFinder.findSchemas(), outputBuildDir, mappingConfig,
- TestUtils.getStaticGeneratedInfo()).generate();
+
+ generate();
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
@@ -70,4 +70,9 @@ void generateClientSideClasses() throws Exception {
getFileByName(files, "EventResponseProjection.java"));
}
+ private void generate() throws IOException {
+ new JavaGraphQLCodegen(schemaFinder.findSchemas(), outputBuildDir, mappingConfig,
+ TestUtils.getStaticGeneratedInfo(mappingConfig)).generate();
+ }
+
}
\ No newline at end of file
diff --git a/src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenExtendTest.java b/src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenExtendTest.java
index 5a64dd72e..8deff685f 100644
--- a/src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenExtendTest.java
+++ b/src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenExtendTest.java
@@ -9,6 +9,7 @@
import org.junit.jupiter.api.Test;
import java.io.File;
+import java.io.IOException;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.HashSet;
@@ -40,8 +41,7 @@ void cleanup() {
@Test
void generateServerSideClasses() throws Exception {
- new JavaGraphQLCodegen(schemaFinder.findSchemas(), outputBuildDir, mappingConfig,
- TestUtils.getStaticGeneratedInfo()).generate();
+ generate();
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
Set generatedFileNames = Arrays.stream(files).map(File::getName).collect(toSet());
@@ -61,8 +61,8 @@ void generateServerSideClasses() throws Exception {
@Test
void generate_onlyExtend() throws Exception {
schemaFinder.setIncludePattern("only-extend-queries.*\\.graphqls");
- new JavaGraphQLCodegen(schemaFinder.findSchemas(), outputBuildDir, mappingConfig,
- TestUtils.getStaticGeneratedInfo()).generate();
+
+ generate();
assertEquals(new HashSet<>(asList("SubscriptionResolver.java", "UserQueryResolver.java", "User.java",
"UsersCreatedSubscriptionResolver.java", "CreateUserMutationResolver.java",
@@ -75,8 +75,8 @@ void generate_onlyExtend() throws Exception {
@Test
void generateServerSideClasses_ExtensionFieldsResolvers() throws Exception {
mappingConfig.setGenerateExtensionFieldsResolvers(true);
- new JavaGraphQLCodegen(schemaFinder.findSchemas(), outputBuildDir, mappingConfig,
- TestUtils.getStaticGeneratedInfo()).generate();
+
+ generate();
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
Set generatedFileNames = Arrays.stream(files).map(File::getName).collect(toSet());
@@ -99,8 +99,8 @@ void generateServerSideClasses_ExtensionFieldsResolvers() throws Exception {
void generateServerSideClasses_ExtensionFieldsResolvers_WithExclusions() throws Exception {
mappingConfig.setGenerateExtensionFieldsResolvers(true);
mappingConfig.setFieldsWithoutResolvers(new HashSet<>(asList("Node", "Event.assets")));
- new JavaGraphQLCodegen(schemaFinder.findSchemas(), outputBuildDir, mappingConfig,
- TestUtils.getStaticGeneratedInfo()).generate();
+
+ generate();
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
Set generatedFileNames = Arrays.stream(files).map(File::getName).collect(toSet());
@@ -121,8 +121,8 @@ void generateServerSideClasses_ExtensionFieldsResolvers_WithExclusions() throws
void generateClientSideClasses() throws Exception {
mappingConfig.setGenerateApis(false);
mappingConfig.setGenerateClient(true);
- new JavaGraphQLCodegen(schemaFinder.findSchemas(), outputBuildDir, mappingConfig,
- TestUtils.getStaticGeneratedInfo()).generate();
+
+ generate();
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
@@ -138,8 +138,8 @@ void generateClientSideClasses() throws Exception {
@Test
void generateServerSideClasses_EmptyTypes() throws Exception {
schemaFinder.setIncludePattern("empty-types-with-extend\\.graphqls");
- new JavaGraphQLCodegen(schemaFinder.findSchemas(), outputBuildDir, mappingConfig,
- TestUtils.getStaticGeneratedInfo()).generate();
+
+ generate();
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
Set generatedFileNames = Arrays.stream(files).map(File::getName).collect(toSet());
@@ -156,4 +156,9 @@ void generateServerSideClasses_EmptyTypes() throws Exception {
}
}
+ private void generate() throws IOException {
+ new JavaGraphQLCodegen(schemaFinder.findSchemas(), outputBuildDir, mappingConfig,
+ TestUtils.getStaticGeneratedInfo(mappingConfig)).generate();
+ }
+
}
\ No newline at end of file
diff --git a/src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenFieldsResolversTest.java b/src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenFieldsResolversTest.java
index 2cc9cadf9..0c8dcecfb 100644
--- a/src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenFieldsResolversTest.java
+++ b/src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenFieldsResolversTest.java
@@ -8,6 +8,7 @@
import org.junit.jupiter.api.Test;
import java.io.File;
+import java.io.IOException;
import java.util.Collections;
import java.util.HashMap;
import java.util.Objects;
@@ -41,8 +42,7 @@ void generate_ParametrizedFields() throws Exception {
singletonList("com.fasterxml.jackson.databind.annotation.JsonDeserialize(" +
"using = com.example.json.DateTimeScalarDeserializer.class)"))));
- new JavaGraphQLCodegen(singletonList("src/test/resources/schemas/github.graphqls"),
- outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo()).generate();
+ generate("src/test/resources/schemas/github.graphqls");
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
@@ -57,8 +57,7 @@ void generate_ParametrizedFieldsInInterface() throws Exception {
mappingConfig.setGenerateClient(true);
mappingConfig.setGenerateApis(false);
- new JavaGraphQLCodegen(singletonList("src/test/resources/schemas/parametrized-input-client.graphqls"),
- outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo()).generate();
+ generate("src/test/resources/schemas/parametrized-input-client.graphqls");
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
assertSameTrimmedContent(new File("src/test/resources/expected-classes/request/" +
@@ -72,8 +71,7 @@ void generate_ParametrizedFieldsInInterface_DoNotGenerateResolvers() throws Exce
mappingConfig.setGenerateApis(false);
mappingConfig.setGenerateParameterizedFieldsResolvers(false);
- new JavaGraphQLCodegen(singletonList("src/test/resources/schemas/parametrized-input-client.graphqls"),
- outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo()).generate();
+ generate("src/test/resources/schemas/parametrized-input-client.graphqls");
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
assertSameTrimmedContent(new File("src/test/resources/expected-classes/resolvers/A.java.txt"),
@@ -89,8 +87,7 @@ void generate_CustomFieldsResolvers() throws Exception {
mappingConfig.setGenerateDataFetchingEnvironmentArgumentInApis(true);
mappingConfig.setFieldsWithResolvers(Collections.singleton("AcceptTopicSuggestionPayload.topic"));
- new JavaGraphQLCodegen(singletonList("src/test/resources/schemas/github.graphqls"),
- outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo()).generate();
+ generate("src/test/resources/schemas/github.graphqls");
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
@@ -106,8 +103,7 @@ void generate_CustomFieldsResolvers() throws Exception {
void generate_ResolverForWholeType() throws Exception {
mappingConfig.setFieldsWithResolvers(Collections.singleton("CommentDeletedEvent"));
- new JavaGraphQLCodegen(singletonList("src/test/resources/schemas/github.graphqls"),
- outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo()).generate();
+ generate("src/test/resources/schemas/github.graphqls");
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
@@ -122,8 +118,7 @@ void generate_FieldResolversViaDirective() throws Exception {
mappingConfig.setFieldsWithResolvers(Collections.singleton("@customResolver"));
mappingConfig.setFieldsWithoutResolvers(Collections.singleton("@noResolver"));
- new JavaGraphQLCodegen(singletonList("src/test/resources/schemas/test.graphqls"),
- outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo()).generate();
+ generate("src/test/resources/schemas/test.graphqls");
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
@@ -139,4 +134,9 @@ void generate_FieldResolversViaDirective() throws Exception {
getFileByName(files, "EventProperty.java"));
}
+ private void generate(String o) throws IOException {
+ new JavaGraphQLCodegen(singletonList(o),
+ outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo(mappingConfig)).generate();
+ }
+
}
\ No newline at end of file
diff --git a/src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenFileCreatorTest.java b/src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenFileCreatorTest.java
index eadfebb54..63a568d05 100644
--- a/src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenFileCreatorTest.java
+++ b/src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenFileCreatorTest.java
@@ -47,12 +47,12 @@ void generateFile() throws IOException {
dataModel.put(DataModelFields.CLASS_NAME, "Class1");
dataModel.put(DataModelFields.ANNOTATIONS, Collections.emptyList());
dataModel.put(DataModelFields.GENERATED_ANNOTATION, false);
- dataModel.put(DataModelFields.GENERATED_INFO, new GeneratedInformation());
+ dataModel.put(DataModelFields.GENERATED_INFO, new GeneratedInformation(mappingConfig));
MappingContext mappingContext = MappingContext.builder()
.setMappingConfig(mappingConfig)
.setDocument(extendedDocument)
- .setGeneratedInformation(new GeneratedInformation())
+ .setGeneratedInformation(new GeneratedInformation(mappingConfig))
.setDataModelMapperFactory(new DataModelMapperFactory(MAPPER_FACTORY))
.setOutputDirectory(OUTPUT_DIR)
.build();
diff --git a/src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenGitHubTest.java b/src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenGitHubTest.java
index 5e6a70437..673f42d4d 100644
--- a/src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenGitHubTest.java
+++ b/src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenGitHubTest.java
@@ -40,8 +40,7 @@ void cleanup() {
@Test
void generate_MultipleInterfacesPerType() throws Exception {
- new JavaGraphQLCodegen(singletonList("src/test/resources/schemas/github.graphqls"),
- outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo()).generate();
+ generate();
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
@@ -57,8 +56,7 @@ void generate_ClassNameWithSuffix_Prefix() throws Exception {
mappingConfig.setModelNamePrefix("Github");
mappingConfig.setModelNameSuffix("TO");
- new JavaGraphQLCodegen(singletonList("src/test/resources/schemas/github.graphqls"),
- outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo()).generate();
+ generate();
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
@@ -88,8 +86,7 @@ void generate_ClassNameWithSuffix_Prefix() throws Exception {
void generate_NoValidationAnnotation() throws Exception {
mappingConfig.setModelValidationAnnotation("");
- new JavaGraphQLCodegen(singletonList("src/test/resources/schemas/github.graphqls"),
- outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo()).generate();
+ generate();
File commitFile = getFileByName(Objects.requireNonNull(outputJavaClassesDir.listFiles()), "Commit.java");
assertSameTrimmedContent(new File("src/test/resources/expected-classes/Commit_noValidationAnnotation.java.txt"),
@@ -101,8 +98,7 @@ void generate_Client_ConditionalFragments() throws Exception {
mappingConfig.setGenerateClient(true);
mappingConfig.setGenerateApis(false);
- new JavaGraphQLCodegen(singletonList("src/test/resources/schemas/github.graphqls"),
- outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo()).generate();
+ generate();
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
assertSameTrimmedContent(new File(
@@ -121,12 +117,16 @@ void generate_NoPrimitives() throws Exception {
mappingConfig.putCustomTypeMappingIfAbsent("Boolean!", "Boolean");
mappingConfig.setUseOptionalForNullableReturnTypes(true);
- new JavaGraphQLCodegen(singletonList("src/test/resources/schemas/github.graphqls"),
- outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo()).generate();
+ generate();
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
assertSameTrimmedContent(new File("src/test/resources/expected-classes/Commit_withoutPrimitives.java.txt"),
getFileByName(files, "Commit.java"));
}
+ private void generate() throws IOException {
+ new JavaGraphQLCodegen(singletonList("src/test/resources/schemas/github.graphqls"),
+ outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo(mappingConfig)).generate();
+ }
+
}
\ No newline at end of file
diff --git a/src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenImmutableTest.java b/src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenImmutableTest.java
index 8771b8a0e..4f040f5cf 100644
--- a/src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenImmutableTest.java
+++ b/src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenImmutableTest.java
@@ -31,7 +31,7 @@ void generate_CheckFiles() throws Exception {
mappingConfig.setGenerateImmutableModels(true);
new JavaGraphQLCodegen(singletonList("src/test/resources/schemas/test.graphqls"),
- outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo()).generate();
+ outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo(mappingConfig)).generate();
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
diff --git a/src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenInterfacesTest.java b/src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenInterfacesTest.java
index eecd2afc5..6e32b0481 100644
--- a/src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenInterfacesTest.java
+++ b/src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenInterfacesTest.java
@@ -28,7 +28,7 @@ class GraphQLCodegenInterfacesTest {
void init() {
mappingConfig.setPackageName("com.kobylynskyi.graphql.interfaces");
generator = new JavaGraphQLCodegen(Collections.singletonList("src/test/resources/schemas/interfaces.graphqls"),
- outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo());
+ outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo(mappingConfig));
}
@AfterEach
diff --git a/src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenIntrospectionResultTest.java b/src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenIntrospectionResultTest.java
index 5872a05f6..a4ff42be9 100644
--- a/src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenIntrospectionResultTest.java
+++ b/src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenIntrospectionResultTest.java
@@ -40,16 +40,14 @@ void cleanup() {
@Test
void generateClientFromIntrospectionResult() throws Exception {
- new JavaGraphQLCodegen("src/test/resources/introspection-result/sample-introspection-query-result.json",
- outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo()).generate();
+ generate("src/test/resources/introspection-result/sample-introspection-query-result.json");
checkGeneratedFiles();
}
@Test
void generateClientFromIntrospectionResultWrappedInData() throws Exception {
- new JavaGraphQLCodegen("src/test/resources/introspection-result/sample-introspection-query-result-wrapped.json",
- outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo()).generate();
+ generate("src/test/resources/introspection-result/sample-introspection-query-result-wrapped.json");
checkGeneratedFiles();
}
@@ -59,12 +57,16 @@ void generateClientFromIntrospectionResult_SetApiStrategies() throws Exception {
mappingConfig.setApiRootInterfaceStrategy(ApiRootInterfaceStrategy.INTERFACE_PER_SCHEMA);
mappingConfig.setApiNamePrefixStrategy(ApiNamePrefixStrategy.FOLDER_NAME_AS_PREFIX);
- new JavaGraphQLCodegen("src/test/resources/introspection-result/sample-introspection-query-result.json",
- outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo()).generate();
+ generate("src/test/resources/introspection-result/sample-introspection-query-result.json");
checkGeneratedFiles();
}
+ private void generate(String path) throws IOException {
+ new JavaGraphQLCodegen(path,
+ outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo(mappingConfig)).generate();
+ }
+
private void checkGeneratedFiles() throws IOException {
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
List generatedFileNames = Arrays.stream(files).map(File::getName).sorted().collect(toList());
diff --git a/src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenModelsForRootTypesTest.java b/src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenModelsForRootTypesTest.java
index b2a6f4ea4..e4333a65a 100644
--- a/src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenModelsForRootTypesTest.java
+++ b/src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenModelsForRootTypesTest.java
@@ -9,6 +9,7 @@
import org.junit.jupiter.api.Test;
import java.io.File;
+import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
@@ -22,7 +23,7 @@ class GraphQLCodegenModelsForRootTypesTest {
public static final List SCHEMAS = singletonList("src/test/resources/schemas/test.graphqls");
private final MappingConfig mappingConfig = new MappingConfig();
- private final GeneratedInformation staticGeneratedInfo = TestUtils.getStaticGeneratedInfo();
+ private final GeneratedInformation staticGeneratedInfo = TestUtils.getStaticGeneratedInfo(mappingConfig);
private final File outputBuildDir = new File("build/generated");
private final File outputJavaClassesDir = new File("build/generated/com/kobylynskyi/graphql/rootmodels");
@@ -67,7 +68,7 @@ void generate_sameResolverSuffixes() {
void generate_CheckFiles_generateApisFalse() throws Exception {
mappingConfig.setGenerateApis(false);
- new JavaGraphQLCodegen(SCHEMAS, outputBuildDir, mappingConfig, staticGeneratedInfo).generate();
+ generate();
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
List generatedFileNames = Arrays.stream(files).map(File::getName).sorted().collect(toList());
@@ -80,7 +81,7 @@ void generate_CheckFiles_generateApisFalse() throws Exception {
void generate_CheckFiles_generateApisTrue_CustomTypeResolverSuffix() throws Exception {
mappingConfig.setTypeResolverSuffix("TypeResolver");
- new JavaGraphQLCodegen(SCHEMAS, outputBuildDir, mappingConfig, staticGeneratedInfo).generate();
+ generate();
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
List generatedFileNames = Arrays.stream(files).map(File::getName).sorted().collect(toList());
@@ -93,4 +94,8 @@ void generate_CheckFiles_generateApisTrue_CustomTypeResolverSuffix() throws Exce
generatedFileNames);
}
+ private void generate() throws IOException {
+ new JavaGraphQLCodegen(SCHEMAS, outputBuildDir, mappingConfig, staticGeneratedInfo).generate();
+ }
+
}
diff --git a/src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenMultiFilesTest.java b/src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenMultiFilesTest.java
index bb45ce98b..35e8d2b8f 100644
--- a/src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenMultiFilesTest.java
+++ b/src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenMultiFilesTest.java
@@ -31,7 +31,8 @@ void init() {
"src/test/resources/schemas/multi1.graphqls",
"src/test/resources/schemas/multi2.graphqls"
);
- generator = new JavaGraphQLCodegen(schemas, outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo());
+ generator = new JavaGraphQLCodegen(schemas, outputBuildDir, mappingConfig,
+ TestUtils.getStaticGeneratedInfo(mappingConfig));
}
@AfterEach
diff --git a/src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenOptionalTest.java b/src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenOptionalTest.java
index 7a24c7ca6..b36831dca 100644
--- a/src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenOptionalTest.java
+++ b/src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenOptionalTest.java
@@ -9,6 +9,7 @@
import org.junit.jupiter.api.Test;
import java.io.File;
+import java.io.IOException;
import java.nio.file.Paths;
import java.util.Objects;
@@ -35,8 +36,8 @@ void cleanup() {
@Test
void generate_Optional() throws Exception {
schemaFinder.setIncludePattern("github.*\\.graphqls");
- new JavaGraphQLCodegen(schemaFinder.findSchemas(), outputBuildDir, mappingConfig,
- TestUtils.getStaticGeneratedInfo()).generate();
+
+ generate();
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
@@ -63,8 +64,7 @@ void generate_OptionalWithCustomApiReturnType() throws Exception {
mappingConfig.setApiReturnType("reactor.core.publisher.Mono");
mappingConfig.setApiReturnListType("reactor.core.publisher.Flux");
- new JavaGraphQLCodegen(schemaFinder.findSchemas(), outputBuildDir, mappingConfig,
- TestUtils.getStaticGeneratedInfo()).generate();
+ generate();
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
@@ -84,8 +84,7 @@ void generate_OptionalFieldInInterfaceAndMandatoryInType() throws Exception {
mappingConfig.setGenerateEqualsAndHashCode(true);
schemaFinder.setIncludePattern("optional-vs-mandatory-types.graphqls");
- new JavaGraphQLCodegen(schemaFinder.findSchemas(), outputBuildDir, mappingConfig,
- TestUtils.getStaticGeneratedInfo()).generate();
+ generate();
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
@@ -97,4 +96,9 @@ void generate_OptionalFieldInInterfaceAndMandatoryInType() throws Exception {
getFileByName(files, "TypeWithMandatoryField.java"));
}
+ private void generate() throws IOException {
+ new JavaGraphQLCodegen(schemaFinder.findSchemas(), outputBuildDir, mappingConfig,
+ TestUtils.getStaticGeneratedInfo(mappingConfig)).generate();
+ }
+
}
\ No newline at end of file
diff --git a/src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenParentInterfacesTest.java b/src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenParentInterfacesTest.java
index 29344841f..9df11bfd8 100644
--- a/src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenParentInterfacesTest.java
+++ b/src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenParentInterfacesTest.java
@@ -37,7 +37,7 @@ void generate_CheckFiles() throws Exception {
mappingConfig.setResolverParentInterface("graphql.kickstart.tools.GraphQLResolver<{{TYPE}}>");
new JavaGraphQLCodegen(singletonList("src/test/resources/schemas/test.graphqls"),
- outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo()).generate();
+ outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo(mappingConfig)).generate();
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
diff --git a/src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenRelayTest.java b/src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenRelayTest.java
index 7cc4826bc..c3c51df21 100644
--- a/src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenRelayTest.java
+++ b/src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenRelayTest.java
@@ -9,6 +9,7 @@
import org.junit.jupiter.api.Test;
import java.io.File;
+import java.io.IOException;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.HashSet;
@@ -41,8 +42,7 @@ void cleanup() {
@Test
void generateServerSideRelayClasses() throws Exception {
- new JavaGraphQLCodegen(schemaFinder.findSchemas(), outputBuildDir, mappingConfig,
- TestUtils.getStaticGeneratedInfo()).generate();
+ generate();
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
Set generatedFileNames = Arrays.stream(files).map(File::getName).collect(toSet());
@@ -60,8 +60,8 @@ void generateServerSideRelayClasses() throws Exception {
void generateServerSideRelayClasses_CustomGenericsConnectionType() throws Exception {
mappingConfig.getRelayConfig()
.setConnectionType("reactor.core.publisher.Mono>");
- new JavaGraphQLCodegen(schemaFinder.findSchemas(), outputBuildDir, mappingConfig,
- TestUtils.getStaticGeneratedInfo()).generate();
+
+ generate();
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
@@ -71,4 +71,9 @@ void generateServerSideRelayClasses_CustomGenericsConnectionType() throws Except
}
+ private void generate() throws IOException {
+ new JavaGraphQLCodegen(schemaFinder.findSchemas(), outputBuildDir, mappingConfig,
+ TestUtils.getStaticGeneratedInfo(mappingConfig)).generate();
+ }
+
}
\ No newline at end of file
diff --git a/src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenRequestTest.java b/src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenRequestTest.java
index d04c1f5d8..e2b790a2b 100644
--- a/src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenRequestTest.java
+++ b/src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenRequestTest.java
@@ -8,6 +8,7 @@
import org.junit.jupiter.api.Test;
import java.io.File;
+import java.io.IOException;
import java.util.Objects;
import static com.kobylynskyi.graphql.codegen.TestUtils.assertSameTrimmedContent;
@@ -42,8 +43,7 @@ void cleanup() {
@Test
void generate_RequestAndResponseProjections() throws Exception {
- new JavaGraphQLCodegen(singletonList("src/test/resources/schemas/test.graphqls"),
- outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo()).generate();
+ generate("src/test/resources/schemas/test.graphqls");
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
@@ -73,8 +73,7 @@ void generate_RequestAndResponseProjections() throws Exception {
@Test
void generate_WithModelSuffix() throws Exception {
mappingConfig.setModelNameSuffix("TO");
- new JavaGraphQLCodegen(singletonList("src/test/resources/schemas/test.graphqls"),
- outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo()).generate();
+ generate("src/test/resources/schemas/test.graphqls");
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
@@ -92,20 +91,18 @@ void generate_WithModelSuffix() throws Exception {
@Test
void generate_WithOutAllMethods() throws Exception {
mappingConfig.setGenerateAllMethodInProjection(false);
- new JavaGraphQLCodegen(singletonList("src/test/resources/schemas/test.graphqls"),
- outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo()).generate();
+ generate("src/test/resources/schemas/test.graphqls");
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
assertSameTrimmedContent(new File("src/test/resources/expected-classes/request/" +
- "EventResponseProjection.java_withoutAll.txt"),
- getFileByName(files, "EventResponseProjection.java"));
+ "EventResponseProjection.java_withoutAll.txt"),
+ getFileByName(files, "EventResponseProjection.java"));
}
@Test
void generate_PrimitivesInsideParametrizedInput() throws Exception {
- new JavaGraphQLCodegen(singletonList("src/test/resources/schemas/parametrized-input-client.graphqls"),
- outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo()).generate();
+ generate("src/test/resources/schemas/parametrized-input-client.graphqls");
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
@@ -116,8 +113,7 @@ void generate_PrimitivesInsideParametrizedInput() throws Exception {
@Test
void generate_RequestAndResponseProjections_github() throws Exception {
- new JavaGraphQLCodegen(singletonList("src/test/resources/schemas/github.graphqls"),
- outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo()).generate();
+ generate("src/test/resources/schemas/github.graphqls");
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
@@ -132,8 +128,7 @@ void generate_RequestAndResponseProjections_github() throws Exception {
@Test
void generate_ToStringIsEnabledForInput() throws Exception {
- new JavaGraphQLCodegen(singletonList("src/test/resources/schemas/github.graphqls"),
- outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo()).generate();
+ generate("src/test/resources/schemas/github.graphqls");
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
@@ -145,8 +140,7 @@ void generate_ToStringIsEnabledForInput() throws Exception {
@Test
void generate_emptyRequestSuffix() throws Exception {
mappingConfig.setRequestSuffix("");
- new JavaGraphQLCodegen(singletonList("src/test/resources/schemas/test.graphqls"),
- outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo()).generate();
+ generate("src/test/resources/schemas/test.graphqls");
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
@@ -157,8 +151,7 @@ void generate_emptyRequestSuffix() throws Exception {
void generate_noApiImportForModelClasses() throws Exception {
mappingConfig.setApiPackageName("com.github.graphql.api");
mappingConfig.setModelPackageName("com.github.graphql");
- new JavaGraphQLCodegen(singletonList("src/test/resources/schemas/test.graphqls"),
- outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo()).generate();
+ generate("src/test/resources/schemas/test.graphqls");
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
@@ -170,8 +163,7 @@ void generate_apiImportForModelClassesIfResolverIsPresent() throws Exception {
mappingConfig.setApiPackageName("com.github.graphql.api");
mappingConfig.setModelPackageName("com.github.graphql");
mappingConfig.setFieldsWithResolvers(singleton("Event"));
- new JavaGraphQLCodegen(singletonList("src/test/resources/schemas/test.graphqls"),
- outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo()).generate();
+ generate("src/test/resources/schemas/test.graphqls");
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
@@ -185,8 +177,7 @@ void generate_apiImportForModelClassesIfResolversExtensions() throws Exception {
mappingConfig.setApiPackageName("com.github.graphql.api");
mappingConfig.setModelPackageName("com.github.graphql");
mappingConfig.setGenerateExtensionFieldsResolvers(true);
- new JavaGraphQLCodegen(singletonList("src/test/resources/schemas/test.graphqls"),
- outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo()).generate();
+ generate("src/test/resources/schemas/test.graphqls");
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
@@ -197,8 +188,7 @@ void generate_apiImportForModelClassesIfResolversExtensions() throws Exception {
@Test
void generate_QueriesWithSameName() throws Exception {
- new JavaGraphQLCodegen(singletonList("src/test/resources/schemas/queries-same-name.graphqls"),
- outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo()).generate();
+ generate("src/test/resources/schemas/queries-same-name.graphqls");
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
@@ -214,8 +204,7 @@ void generate_QueriesWithSameName() throws Exception {
@Test
void generate_ClassesWithoutPrimitiveTypes() throws Exception {
mappingConfig.putCustomTypeMappingIfAbsent("Int!", "Integer");
- new JavaGraphQLCodegen(singletonList("src/test/resources/schemas/test.graphqls"),
- outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo()).generate();
+ generate("src/test/resources/schemas/test.graphqls");
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
@@ -228,8 +217,7 @@ void generate_ClassesWithoutPrimitiveTypes() throws Exception {
void generate_UseObjectMapperToSerializeFields_Type() throws Exception {
mappingConfig.putCustomTypeMappingIfAbsent("DateTime", "java.time.ZonedDateTime");
mappingConfig.setUseObjectMapperForRequestSerialization(singleton("DateTime"));
- new JavaGraphQLCodegen(singletonList("src/test/resources/schemas/test.graphqls"),
- outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo()).generate();
+ generate("src/test/resources/schemas/test.graphqls");
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
@@ -242,8 +230,8 @@ void generate_UseObjectMapperToSerializeFields_Type() throws Exception {
void generate_UseObjectMapperToSerializeFields_Field() throws Exception {
mappingConfig.putCustomTypeMappingIfAbsent("Event.createdDateTime", "java.time.ZonedDateTime");
mappingConfig.setUseObjectMapperForRequestSerialization(singleton("DateTime"));
- new JavaGraphQLCodegen(singletonList("src/test/resources/schemas/test.graphqls"),
- outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo()).generate();
+
+ generate("src/test/resources/schemas/test.graphqls");
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
@@ -255,8 +243,8 @@ void generate_UseObjectMapperToSerializeFields_Field() throws Exception {
@Test
void generate_UseObjectMapperToSerializeFields_Parameter() throws Exception {
mappingConfig.setUseObjectMapperForRequestSerialization(singleton("ZonedDateTime"));
- new JavaGraphQLCodegen(singletonList("src/test/resources/schemas/date-scalar.graphqls"),
- outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo()).generate();
+
+ generate("src/test/resources/schemas/date-scalar.graphqls");
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
@@ -265,4 +253,10 @@ void generate_UseObjectMapperToSerializeFields_Parameter() throws Exception {
getFileByName(files, "QueryINeedQueryRequest.java"));
}
+ private void generate(String o) throws IOException {
+ new JavaGraphQLCodegen(singletonList(o), outputBuildDir, mappingConfig,
+ TestUtils.getStaticGeneratedInfo(mappingConfig))
+ .generate();
+ }
+
}
diff --git a/src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenResponseTest.java b/src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenResponseTest.java
index 32fb4e604..ee93f962f 100644
--- a/src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenResponseTest.java
+++ b/src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenResponseTest.java
@@ -8,6 +8,7 @@
import org.junit.jupiter.api.Test;
import java.io.File;
+import java.io.IOException;
import java.util.Objects;
import static com.kobylynskyi.graphql.codegen.TestUtils.assertSameTrimmedContent;
@@ -36,8 +37,8 @@ void cleanup() {
@Test
void generate_RequestAndResponseProjections() throws Exception {
mappingConfig.setModelNameSuffix("TO");
- new JavaGraphQLCodegen(singletonList("src/test/resources/schemas/test.graphqls"),
- outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo()).generate();
+
+ generate("src/test/resources/schemas/test.graphqls");
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
@@ -55,8 +56,8 @@ void generate_RequestAndResponseProjections() throws Exception {
@Test
void generate_RequestAndResponseProjections_Interfaces() throws Exception {
mappingConfig.setModelNameSuffix("TO");
- new JavaGraphQLCodegen(singletonList("src/test/resources/schemas/projection-interfaces.graphqls"),
- outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo()).generate();
+
+ generate("src/test/resources/schemas/projection-interfaces.graphqls");
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
@@ -71,8 +72,8 @@ void generate_RequestAndResponseProjections_Interfaces() throws Exception {
@Test
void generate_projections_with_selectAll() throws Exception {
mappingConfig.setModelNameSuffix("TO");
- new JavaGraphQLCodegen(singletonList("src/test/resources/schemas/projection-interfaces.graphqls"),
- outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo()).generate();
+
+ generate("src/test/resources/schemas/projection-interfaces.graphqls");
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
@@ -86,8 +87,7 @@ void generate_projections_with_selectAll() throws Exception {
@Test
void generate_ResponseWithPrimitiveType() throws Exception {
- new JavaGraphQLCodegen(singletonList("src/test/resources/schemas/primitive-query-response-type.graphqls"),
- outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo()).generate();
+ generate("src/test/resources/schemas/primitive-query-response-type.graphqls");
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
@@ -96,4 +96,9 @@ void generate_ResponseWithPrimitiveType() throws Exception {
getFileByName(files, "VersionQueryResponse.java"));
}
+ private void generate(String o) throws IOException {
+ new JavaGraphQLCodegen(singletonList(o),
+ outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo(mappingConfig)).generate();
+ }
+
}
\ No newline at end of file
diff --git a/src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenRestrictedWordsTest.java b/src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenRestrictedWordsTest.java
index 9def4f494..c10e985c2 100644
--- a/src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenRestrictedWordsTest.java
+++ b/src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenRestrictedWordsTest.java
@@ -39,7 +39,7 @@ void generate() throws Exception {
mappingConfig.setApiNameSuffix("API");
new JavaGraphQLCodegen(singletonList("src/test/resources/schemas/restricted-words.graphqls"),
- outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo()).generate();
+ outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo(mappingConfig)).generate();
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
List generatedFileNames = Arrays.stream(files).map(File::getName).sorted().collect(toList());
diff --git a/src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenTest.java b/src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenTest.java
index ce083407f..7b1b08b6a 100644
--- a/src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenTest.java
+++ b/src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenTest.java
@@ -250,7 +250,7 @@ void generate_GeneratedAnnotation() throws Exception {
@Test
void generate_NoSchemas() {
- GeneratedInformation staticGeneratedInfo = TestUtils.getStaticGeneratedInfo();
+ GeneratedInformation staticGeneratedInfo = TestUtils.getStaticGeneratedInfo(mappingConfig);
List schemas = emptyList();
JavaGraphQLCodegen codegen = new JavaGraphQLCodegen(
schemas, outputBuildDir, mappingConfig, staticGeneratedInfo);
@@ -261,7 +261,7 @@ void generate_NoSchemas() {
void generate_WrongSchema() {
GraphQLCodegen graphQLCodegen = new JavaGraphQLCodegen(
singletonList("src/test/resources/schemas/wrong.graphqls"),
- outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo());
+ outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo(mappingConfig));
assertThrows(NoSuchFileException.class, graphQLCodegen::generate);
@@ -401,7 +401,7 @@ void generate_InterfaceAndTypeHavingDuplicateFields1() throws Exception {
private List generate(String s) throws IOException {
return new JavaGraphQLCodegen(singletonList(s), outputBuildDir, mappingConfig,
- TestUtils.getStaticGeneratedInfo()).generate();
+ TestUtils.getStaticGeneratedInfo(mappingConfig)).generate();
}
}
diff --git a/src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenTypesAsInterfacesTest.java b/src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenTypesAsInterfacesTest.java
index 5eeff536d..50cb752dd 100644
--- a/src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenTypesAsInterfacesTest.java
+++ b/src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenTypesAsInterfacesTest.java
@@ -8,12 +8,12 @@
import org.junit.jupiter.api.Test;
import java.io.File;
+import java.io.IOException;
import java.util.HashSet;
import java.util.Objects;
import static com.kobylynskyi.graphql.codegen.TestUtils.assertSameTrimmedContent;
import static com.kobylynskyi.graphql.codegen.TestUtils.getFileByName;
-import static java.util.Arrays.asList;
import static java.util.Collections.singleton;
import static java.util.Collections.singletonList;
@@ -40,8 +40,7 @@ void cleanup() {
void generate_typesAsInterfaces() throws Exception {
mappingConfig.getTypesAsInterfaces().add("Order");
- new JavaGraphQLCodegen(singletonList("src/test/resources/schemas/types-as-interfaces.graphqls"),
- outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo()).generate();
+ generate("src/test/resources/schemas/types-as-interfaces.graphqls");
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
@@ -59,11 +58,9 @@ void generate_typesAsInterfaces() throws Exception {
@Test
void generate_typesAsInterfacesExtendsInterface() throws Exception {
- mappingConfig.setTypesAsInterfaces(new HashSet<>(asList("@asInterface")));
+ mappingConfig.setTypesAsInterfaces(new HashSet<>(singletonList("@asInterface")));
- new JavaGraphQLCodegen(singletonList("src/test/resources/schemas/" +
- "types-as-interfaces-extends-interface.graphqls"),
- outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo()).generate();
+ generate("src/test/resources/schemas/types-as-interfaces-extends-interface.graphqls");
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
@@ -86,9 +83,7 @@ void generate_typesAsInterfacesExtendsInterface() throws Exception {
void generate_typeAsInterfaceParametrized() throws Exception {
mappingConfig.setGenerateParameterizedFieldsResolvers(true);
- new JavaGraphQLCodegen(singletonList("src/test/resources/schemas/" +
- "types-as-interfaces-parametrized.graphqls"),
- outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo()).generate();
+ generate("src/test/resources/schemas/types-as-interfaces-parametrized.graphqls");
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
@@ -97,4 +92,10 @@ void generate_typeAsInterfaceParametrized() throws Exception {
getFileByName(files, "Foo.java"));
}
+ private void generate(String o) throws IOException {
+ new JavaGraphQLCodegen(singletonList(o), outputBuildDir, mappingConfig,
+ TestUtils.getStaticGeneratedInfo(mappingConfig))
+ .generate();
+ }
+
}
diff --git a/src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenUnionResolverTest.java b/src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenUnionResolverTest.java
index bdfbf6a1c..25dbdc3e8 100644
--- a/src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenUnionResolverTest.java
+++ b/src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenUnionResolverTest.java
@@ -38,7 +38,8 @@ void cleanup() {
@Test
void generate_CheckFiles_with_model_package() throws Exception {
mappingConfig.setPackageName("com.kobylynskyi.graphql.unionresolver");
- generate("src/test/resources/schemas/union-resolver.graphqls");
+
+ generate();
File outputJavaClassesDir = new File("build/generated/com/kobylynskyi/graphql/unionresolver");
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
@@ -60,7 +61,8 @@ void generate_CheckFiles_with_model_package() throws Exception {
void generate_CheckFiles_without_model_package_and_with_prefix_and_suffix() throws Exception {
mappingConfig.setModelNamePrefix("My");
mappingConfig.setModelNameSuffix("Suffix");
- generate("src/test/resources/schemas/union-resolver.graphqls");
+
+ generate();
File outputJavaClassesDir = new File("build/generated");
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
@@ -78,9 +80,10 @@ void generate_CheckFiles_without_model_package_and_with_prefix_and_suffix() thro
}
}
- private void generate(String path) throws IOException {
- new JavaGraphQLCodegen(singletonList(path), outputBuildDir, mappingConfig,
- TestUtils.getStaticGeneratedInfo()).generate();
+ private void generate() throws IOException {
+ new JavaGraphQLCodegen(singletonList("src/test/resources/schemas/union-resolver.graphqls"),
+ outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo(mappingConfig))
+ .generate();
}
}
diff --git a/src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenUnionWithEnumTest.java b/src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenUnionWithEnumTest.java
index b4905f841..10f3b99fb 100644
--- a/src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenUnionWithEnumTest.java
+++ b/src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenUnionWithEnumTest.java
@@ -32,7 +32,7 @@ void cleanup() {
void generate_CheckFiles() throws Exception {
mappingConfig.setPackageName("com.kobylynskyi.graphql.enumunion");
new JavaGraphQLCodegen(singletonList("src/test/resources/schemas/union-with-enum.graphqls"),
- outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo())
+ outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo(mappingConfig))
.generate();
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
diff --git a/src/test/java/com/kobylynskyi/graphql/codegen/TestUtils.java b/src/test/java/com/kobylynskyi/graphql/codegen/TestUtils.java
index 3635f262d..ba87e3f44 100644
--- a/src/test/java/com/kobylynskyi/graphql/codegen/TestUtils.java
+++ b/src/test/java/com/kobylynskyi/graphql/codegen/TestUtils.java
@@ -1,6 +1,7 @@
package com.kobylynskyi.graphql.codegen;
import com.kobylynskyi.graphql.codegen.model.GeneratedInformation;
+import com.kobylynskyi.graphql.codegen.model.MappingConfig;
import com.kobylynskyi.graphql.codegen.utils.Utils;
import org.hamcrest.Matchers;
@@ -53,10 +54,8 @@ private static boolean atLeastJava9() {
}
}
- public static GeneratedInformation getStaticGeneratedInfo() {
- GeneratedInformation generatedInformation = new GeneratedInformation();
- generatedInformation.setDateTimeSupplier(() -> GENERATED_DATE_TIME);
- return generatedInformation;
+ public static GeneratedInformation getStaticGeneratedInfo(MappingConfig mappingConfig) {
+ return new GeneratedInformation(() -> GENERATED_DATE_TIME, mappingConfig);
}
}
diff --git a/src/test/java/com/kobylynskyi/graphql/codegen/kotlin/GraphQLCodegenCustomScalarMappingTest.java b/src/test/java/com/kobylynskyi/graphql/codegen/kotlin/GraphQLCodegenCustomScalarMappingTest.java
index d1486986a..8277ee1b7 100644
--- a/src/test/java/com/kobylynskyi/graphql/codegen/kotlin/GraphQLCodegenCustomScalarMappingTest.java
+++ b/src/test/java/com/kobylynskyi/graphql/codegen/kotlin/GraphQLCodegenCustomScalarMappingTest.java
@@ -9,6 +9,7 @@
import org.junit.jupiter.api.Test;
import java.io.File;
+import java.io.IOException;
import java.util.HashMap;
import java.util.Objects;
@@ -43,8 +44,7 @@ void cleanup() {
void generate_CustomTypeMapping_WholeScalar() throws Exception {
mappingConfig.setCustomTypesMapping(new HashMap<>(singletonMap("ZonedDateTime", "String")));
- new KotlinGraphQLCodegen(singletonList("src/test/resources/schemas/date-scalar.graphqls"),
- outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo()).generate();
+ generate("src/test/resources/schemas/date-scalar.graphqls");
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
@@ -61,8 +61,7 @@ void generate_CustomTypeMapping_ScalarOnQueryOnly() throws Exception {
customTypesMapping.put("ZonedDateTime", "java.time.ZonedDateTime");
mappingConfig.setCustomTypesMapping(customTypesMapping);
- new KotlinGraphQLCodegen(singletonList("src/test/resources/schemas/date-scalar.graphqls"),
- outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo()).generate();
+ generate("src/test/resources/schemas/date-scalar.graphqls");
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
@@ -81,8 +80,8 @@ void generate_UseObjectMapperToSerializeFields_Parameter() throws Exception {
customTypesMapping.put("ZonedDateTime", "java.time.ZonedDateTime");
mappingConfig.setCustomTypesMapping(customTypesMapping);
mappingConfig.setUseObjectMapperForRequestSerialization(singleton("ZonedDateTime"));
- new KotlinGraphQLCodegen(singletonList("src/test/resources/schemas/date-scalar.graphqls"),
- outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo()).generate();
+
+ generate("src/test/resources/schemas/date-scalar.graphqls");
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
@@ -95,8 +94,8 @@ void generate_UseObjectMapperToSerializeFields_Parameter() throws Exception {
void generate_UseObjectMapperToSerializeFields_Type() throws Exception {
mappingConfig.putCustomTypeMappingIfAbsent("DateTime", "java.time.LocalDateTime");
mappingConfig.setUseObjectMapperForRequestSerialization(singleton("DateTime"));
- new KotlinGraphQLCodegen(singletonList("src/test/resources/schemas/test.graphqls"),
- outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo()).generate();
+
+ generate("src/test/resources/schemas/test.graphqls");
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
@@ -104,4 +103,10 @@ void generate_UseObjectMapperToSerializeFields_Type() throws Exception {
"Event_useObjectMapperForRequestSerialization.kt.txt"),
getFileByName(files, "Event.kt"));
}
+
+ private void generate(String path) throws IOException {
+ new KotlinGraphQLCodegen(singletonList(path), outputBuildDir, mappingConfig,
+ TestUtils.getStaticGeneratedInfo(mappingConfig)).generate();
+ }
+
}
diff --git a/src/test/java/com/kobylynskyi/graphql/codegen/kotlin/GraphQLCodegenDeprecatedTest.java b/src/test/java/com/kobylynskyi/graphql/codegen/kotlin/GraphQLCodegenDeprecatedTest.java
index 7662cd652..6c0ebe076 100644
--- a/src/test/java/com/kobylynskyi/graphql/codegen/kotlin/GraphQLCodegenDeprecatedTest.java
+++ b/src/test/java/com/kobylynskyi/graphql/codegen/kotlin/GraphQLCodegenDeprecatedTest.java
@@ -40,7 +40,7 @@ void cleanup() {
@Test
void generate_deprecated() throws Exception {
new KotlinGraphQLCodegen(Collections.singletonList("src/test/resources/schemas/deprecated-with-msg.graphqls"),
- outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo()).generate();
+ outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo(mappingConfig)).generate();
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
List generatedFileNames = Arrays.stream(files).map(File::getName).sorted().collect(toList());
diff --git a/src/test/java/com/kobylynskyi/graphql/codegen/kotlin/GraphQLCodegenEmptyTest.java b/src/test/java/com/kobylynskyi/graphql/codegen/kotlin/GraphQLCodegenEmptyTest.java
index 8124f7757..34bbe65b7 100644
--- a/src/test/java/com/kobylynskyi/graphql/codegen/kotlin/GraphQLCodegenEmptyTest.java
+++ b/src/test/java/com/kobylynskyi/graphql/codegen/kotlin/GraphQLCodegenEmptyTest.java
@@ -45,7 +45,7 @@ void cleanup() {
@Test
void generateServerSideClasses() throws Exception {
new ScalaGraphQLCodegen(schemaFinder.findSchemas(), outputBuildDir, mappingConfig,
- TestUtils.getStaticGeneratedInfo()).generate();
+ TestUtils.getStaticGeneratedInfo(mappingConfig)).generate();
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
Set generatedFileNames = Arrays.stream(files).map(File::getName).collect(toSet());
@@ -65,7 +65,7 @@ void generateClientSideClasses() throws Exception {
mappingConfig.setGenerateApis(false);
mappingConfig.setGenerateClient(true);
new JavaGraphQLCodegen(schemaFinder.findSchemas(), outputBuildDir, mappingConfig,
- TestUtils.getStaticGeneratedInfo()).generate();
+ TestUtils.getStaticGeneratedInfo(mappingConfig)).generate();
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
diff --git a/src/test/java/com/kobylynskyi/graphql/codegen/kotlin/GraphQLCodegenGitHubTest.java b/src/test/java/com/kobylynskyi/graphql/codegen/kotlin/GraphQLCodegenGitHubTest.java
index c3d92c1ab..1a7016415 100644
--- a/src/test/java/com/kobylynskyi/graphql/codegen/kotlin/GraphQLCodegenGitHubTest.java
+++ b/src/test/java/com/kobylynskyi/graphql/codegen/kotlin/GraphQLCodegenGitHubTest.java
@@ -4,7 +4,6 @@
import com.kobylynskyi.graphql.codegen.model.GeneratedLanguage;
import com.kobylynskyi.graphql.codegen.model.MappingConfig;
import com.kobylynskyi.graphql.codegen.utils.Utils;
-import org.hamcrest.core.StringContains;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -16,12 +15,11 @@
import java.util.Objects;
import java.util.Set;
+import static com.kobylynskyi.graphql.codegen.TestUtils.assertFileContainsElements;
import static com.kobylynskyi.graphql.codegen.TestUtils.assertSameTrimmedContent;
import static com.kobylynskyi.graphql.codegen.TestUtils.getFileByName;
import static java.util.Collections.singleton;
import static java.util.Collections.singletonList;
-import static org.hamcrest.MatcherAssert.assertThat;
-
class GraphQLCodegenGitHubTest {
@@ -29,10 +27,6 @@ class GraphQLCodegenGitHubTest {
private final File outputktClassesDir = new File("build/generated/com/github/graphql");
private final MappingConfig mappingConfig = new MappingConfig();
- private static String getFileContent(File[] files, String fileName) throws IOException {
- return Utils.getFileContent(getFileByName(files, fileName).getPath());
- }
-
@BeforeEach
void init() {
mappingConfig.setGenerateParameterizedFieldsResolvers(false);
@@ -55,8 +49,8 @@ void generate_MultipleInterfacesPerType() throws Exception {
mappingConfig.putCustomTypeMappingIfAbsent("Boolean!", "Boolean");
mappingConfig.setUseOptionalForNullableReturnTypes(true);
- new KotlinGraphQLCodegen(singletonList("src/test/resources/schemas/github.graphqls"),
- outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo()).generate();
+ generate("src/test/resources/schemas/github.graphqls");
+
File[] files = Objects.requireNonNull(outputktClassesDir.listFiles());
assertSameTrimmedContent(new File("src/test/resources/expected-classes/kt/Commit.kt.txt"),
@@ -76,22 +70,18 @@ void generate_ClassNameWithSuffix_Prefix() throws Exception {
mappingConfig.setModelNameSuffix("TO");
mappingConfig.setGenerateImmutableModels(false);
- new KotlinGraphQLCodegen(singletonList("src/test/resources/schemas/github.graphqls"),
- outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo()).generate();
+ generate("src/test/resources/schemas/github.graphqls");
File[] files = Objects.requireNonNull(outputktClassesDir.listFiles());
// verify proper class name for GraphQL interface
- assertThat(getFileContent(files, "GithubActorTO.kt"),
- StringContains.containsString("interface GithubActorTO"));
+ assertFileContainsElements(files, "GithubActorTO.kt", "interface GithubActorTO");
// verify proper class name for GraphQL enum
- assertThat(getFileContent(files, "GithubIssueStateTO.kt"),
- StringContains.containsString("enum class GithubIssueStateTO"));
+ assertFileContainsElements(files, "GithubIssueStateTO.kt", "enum class GithubIssueStateTO");
// verify proper class name for GraphQL union
- assertThat(getFileContent(files, "GithubAssigneeTO.kt"),
- StringContains.containsString("interface GithubAssigneeTO"));
+ assertFileContainsElements(files, "GithubAssigneeTO.kt", "interface GithubAssigneeTO");
// verify proper class name for GraphQL input
assertSameTrimmedContent(
@@ -108,8 +98,7 @@ void generate_Client_ConditionalFragments() throws Exception {
mappingConfig.setGenerateClient(true);
mappingConfig.setGenerateApis(false);
- new KotlinGraphQLCodegen(singletonList("src/test/resources/schemas/github.graphqls"),
- outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo()).generate();
+ generate("src/test/resources/schemas/github.graphqls");
File[] files = Objects.requireNonNull(outputktClassesDir.listFiles());
assertSameTrimmedContent(
@@ -124,8 +113,7 @@ void generate_Client_ConditionalFragments() throws Exception {
void generate_ResponseWithPrimitiveType() throws Exception {
mappingConfig.putCustomTypeMappingIfAbsent("Int!", "Int");
mappingConfig.putCustomTypeMappingIfAbsent("Int", "Int?");
- new KotlinGraphQLCodegen(singletonList("src/test/resources/schemas/primitive-query-response-type.graphqls"),
- outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo()).generate();
+ generate("src/test/resources/schemas/primitive-query-response-type.graphqls");
File[] files = Objects.requireNonNull(outputktClassesDir.listFiles());
@@ -135,8 +123,7 @@ void generate_ResponseWithPrimitiveType() throws Exception {
@Test
void generate_ktList() throws Exception {
- new KotlinGraphQLCodegen(singletonList("src/test/resources/schemas/github.graphqls"),
- outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo()).generate();
+ generate("src/test/resources/schemas/github.graphqls");
File[] files = Objects.requireNonNull(outputktClassesDir.listFiles());
assertSameTrimmedContent(new File("src/test/resources/expected-classes/kt/AddLabelsToLabelableInput.kt.txt"),
@@ -161,8 +148,7 @@ void generate_ktList() throws Exception {
void generate_Var_Field() throws Exception {
mappingConfig.setGenerateImmutableModels(false);
- new KotlinGraphQLCodegen(singletonList("src/test/resources/schemas/github.graphqls"),
- outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo()).generate();
+ generate("src/test/resources/schemas/github.graphqls");
File[] files = Objects.requireNonNull(outputktClassesDir.listFiles());
assertSameTrimmedContent(new File("src/test/resources/expected-classes/kt/Commit_Var_Field.kt.txt"),
@@ -176,8 +162,7 @@ void generate_CustomFieldsResolvers() throws Exception {
mappingConfig.setGenerateDataFetchingEnvironmentArgumentInApis(true);
mappingConfig.setFieldsWithResolvers(Collections.singleton("AcceptTopicSuggestionPayload.topic"));
- new KotlinGraphQLCodegen(singletonList("src/test/resources/schemas/github.graphqls"),
- outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo()).generate();
+ generate("src/test/resources/schemas/github.graphqls");
File[] files = Objects.requireNonNull(outputktClassesDir.listFiles());
@@ -200,8 +185,7 @@ void generate_CustomFieldsResolversWithAnnotation() throws Exception {
mappingConfig.setGenerateDataFetchingEnvironmentArgumentInApis(true);
mappingConfig.setFieldsWithResolvers(Collections.singleton("AcceptTopicSuggestionPayload.topic"));
- new KotlinGraphQLCodegen(singletonList("src/test/resources/schemas/github.graphqls"),
- outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo()).generate();
+ generate("src/test/resources/schemas/github.graphqls");
File[] files = Objects.requireNonNull(outputktClassesDir.listFiles());
@@ -213,7 +197,6 @@ void generate_CustomFieldsResolversWithAnnotation() throws Exception {
@Test
void generate_CustomFieldsResolversWithMultipleAnnotations() throws Exception {
-
Set annotations = new HashSet<>();
annotations.add("some.Annotation");
annotations.add("another.Annotation");
@@ -225,8 +208,7 @@ void generate_CustomFieldsResolversWithMultipleAnnotations() throws Exception {
mappingConfig.setGenerateDataFetchingEnvironmentArgumentInApis(true);
mappingConfig.setFieldsWithResolvers(Collections.singleton("AcceptTopicSuggestionPayload.topic"));
- new KotlinGraphQLCodegen(singletonList("src/test/resources/schemas/github.graphqls"),
- outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo()).generate();
+ generate("src/test/resources/schemas/github.graphqls");
File[] files = Objects.requireNonNull(outputktClassesDir.listFiles());
@@ -240,12 +222,18 @@ void generate_CustomFieldsResolversWithMultipleAnnotations() throws Exception {
void generate_RequestWithDefaultValue() throws Exception {
mappingConfig.setGenerateBuilder(true);
mappingConfig.setGenerateClient(true);
- new KotlinGraphQLCodegen(singletonList("src/test/resources/schemas/kt/default.graphqls"),
- outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo()).generate();
+
+ generate("src/test/resources/schemas/kt/default.graphqls");
+
File[] files = Objects.requireNonNull(outputktClassesDir.listFiles());
assertSameTrimmedContent(new File("src/test/resources/expected-classes/kt/default/" +
"FriendsQueryRequest.kt.txt"),
getFileByName(files, "FriendsQueryRequest.kt"));
}
+ private void generate(String path) throws IOException {
+ new KotlinGraphQLCodegen(singletonList(path),
+ outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo(mappingConfig)).generate();
+ }
+
}
diff --git a/src/test/java/com/kobylynskyi/graphql/codegen/kotlin/GraphQLCodegenInitializeNullableTypesTest.java b/src/test/java/com/kobylynskyi/graphql/codegen/kotlin/GraphQLCodegenInitializeNullableTypesTest.java
index ee4460dc6..369554f46 100644
--- a/src/test/java/com/kobylynskyi/graphql/codegen/kotlin/GraphQLCodegenInitializeNullableTypesTest.java
+++ b/src/test/java/com/kobylynskyi/graphql/codegen/kotlin/GraphQLCodegenInitializeNullableTypesTest.java
@@ -42,7 +42,7 @@ void cleanup() {
@Test
void generate_InitializeNullableTypes() throws Exception {
new KotlinGraphQLCodegen(singletonList("src/test/resources/schemas/github.graphqls"),
- outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo()).generate();
+ outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo(mappingConfig)).generate();
File[] files = Objects.requireNonNull(outputScalaClassesDir.listFiles());
assertSameTrimmedContent(
diff --git a/src/test/java/com/kobylynskyi/graphql/codegen/kotlin/GraphQLCodegenInterfacesTest.java b/src/test/java/com/kobylynskyi/graphql/codegen/kotlin/GraphQLCodegenInterfacesTest.java
index 805680375..30c7da047 100644
--- a/src/test/java/com/kobylynskyi/graphql/codegen/kotlin/GraphQLCodegenInterfacesTest.java
+++ b/src/test/java/com/kobylynskyi/graphql/codegen/kotlin/GraphQLCodegenInterfacesTest.java
@@ -32,7 +32,7 @@ void init() {
mappingConfig.setPackageName("com.kobylynskyi.graphql.interfaces");
generator = new KotlinGraphQLCodegen(
Collections.singletonList("src/test/resources/schemas/interfaces.graphqls"),
- outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo());
+ outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo(mappingConfig));
}
@AfterEach
diff --git a/src/test/java/com/kobylynskyi/graphql/codegen/kotlin/GraphQLCodegenNullableTest.java b/src/test/java/com/kobylynskyi/graphql/codegen/kotlin/GraphQLCodegenNullableTest.java
index 5809ac722..60815e0a8 100644
--- a/src/test/java/com/kobylynskyi/graphql/codegen/kotlin/GraphQLCodegenNullableTest.java
+++ b/src/test/java/com/kobylynskyi/graphql/codegen/kotlin/GraphQLCodegenNullableTest.java
@@ -10,6 +10,7 @@
import org.junit.jupiter.api.Test;
import java.io.File;
+import java.io.IOException;
import java.nio.file.Paths;
import java.util.Objects;
@@ -38,8 +39,8 @@ void generatePrimitiveTypesResponseResolverClasses_nullable() throws Exception {
mappingConfig.setGenerateApis(true);
mappingConfig.setGenerateClient(true);
schemaFinder.setIncludePattern("nullable-extend.graphqls");
- new KotlinGraphQLCodegen(schemaFinder.findSchemas(), outputBuildDir, mappingConfig,
- TestUtils.getStaticGeneratedInfo()).generate();
+
+ generate();
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
@@ -79,8 +80,8 @@ void generatePrimitiveTypesResponseResolverClasses_nullable_With_Prefix_Suffix()
mappingConfig.setModelNamePrefix("Test");
mappingConfig.setModelNameSuffix("DTO");
schemaFinder.setIncludePattern("nullable-extend.graphqls");
- new KotlinGraphQLCodegen(schemaFinder.findSchemas(), outputBuildDir, mappingConfig,
- TestUtils.getStaticGeneratedInfo()).generate();
+
+ generate();
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
assertSameTrimmedContent(
@@ -98,9 +99,7 @@ void generate_OptionalFieldInInterfaceAndMandatoryInType() throws Exception {
mappingConfig.setGenerateEqualsAndHashCode(true);
schemaFinder.setIncludePattern("optional-vs-mandatory-types.graphqls");
- new KotlinGraphQLCodegen(schemaFinder.findSchemas(), outputBuildDir, mappingConfig,
- TestUtils.getStaticGeneratedInfo())
- .generate();
+ generate();
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
@@ -111,4 +110,10 @@ void generate_OptionalFieldInInterfaceAndMandatoryInType() throws Exception {
new File("src/test/resources/expected-classes/kt/optional/TypeWithMandatoryField.kt.txt"),
getFileByName(files, "TypeWithMandatoryField.kt"));
}
+
+ private void generate() throws IOException {
+ new KotlinGraphQLCodegen(schemaFinder.findSchemas(), outputBuildDir, mappingConfig,
+ TestUtils.getStaticGeneratedInfo(mappingConfig))
+ .generate();
+ }
}
diff --git a/src/test/java/com/kobylynskyi/graphql/codegen/kotlin/GraphQLCodegenOpenclassesTest.java b/src/test/java/com/kobylynskyi/graphql/codegen/kotlin/GraphQLCodegenOpenclassesTest.java
index 6b8c81609..c7d59a5ae 100644
--- a/src/test/java/com/kobylynskyi/graphql/codegen/kotlin/GraphQLCodegenOpenclassesTest.java
+++ b/src/test/java/com/kobylynskyi/graphql/codegen/kotlin/GraphQLCodegenOpenclassesTest.java
@@ -42,7 +42,7 @@ void cleanup() {
@Test
void generate_MultipleInterfacesPerType() throws Exception {
new KotlinGraphQLCodegen(singletonList("src/test/resources/schemas/github.graphqls"),
- outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo()).generate();
+ outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo(mappingConfig)).generate();
File[] files = Objects.requireNonNull(outputScalaClassesDir.listFiles());
assertSameTrimmedContent(new File("src/test/resources/expected-classes/kt/Commit_no_final_class.kt.txt"),
diff --git a/src/test/java/com/kobylynskyi/graphql/codegen/kotlin/GraphQLCodegenRelayTest.java b/src/test/java/com/kobylynskyi/graphql/codegen/kotlin/GraphQLCodegenRelayTest.java
index fc5d62209..aa21056e9 100644
--- a/src/test/java/com/kobylynskyi/graphql/codegen/kotlin/GraphQLCodegenRelayTest.java
+++ b/src/test/java/com/kobylynskyi/graphql/codegen/kotlin/GraphQLCodegenRelayTest.java
@@ -10,6 +10,7 @@
import org.junit.jupiter.api.Test;
import java.io.File;
+import java.io.IOException;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.HashSet;
@@ -43,8 +44,7 @@ void cleanup() {
@Test
void generateServerSideRelayClasses() throws Exception {
- new KotlinGraphQLCodegen(schemaFinder.findSchemas(), outputBuildDir, mappingConfig,
- TestUtils.getStaticGeneratedInfo()).generate();
+ generate();
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
Set generatedFileNames = Arrays.stream(files).map(File::getName).collect(toSet());
@@ -62,8 +62,8 @@ void generateServerSideRelayClasses() throws Exception {
void generateServerSideRelayClasses_CustomGenericsConnectionType() throws Exception {
mappingConfig.getRelayConfig()
.setConnectionType("reactor.core.publisher.Mono>");
- new KotlinGraphQLCodegen(schemaFinder.findSchemas(), outputBuildDir, mappingConfig,
- TestUtils.getStaticGeneratedInfo()).generate();
+
+ generate();
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
@@ -73,4 +73,9 @@ void generateServerSideRelayClasses_CustomGenericsConnectionType() throws Except
}
+ private void generate() throws IOException {
+ new KotlinGraphQLCodegen(schemaFinder.findSchemas(), outputBuildDir, mappingConfig,
+ TestUtils.getStaticGeneratedInfo(mappingConfig)).generate();
+ }
+
}
\ No newline at end of file
diff --git a/src/test/java/com/kobylynskyi/graphql/codegen/kotlin/GraphQLCodegenRestrictedWordsAndParameterInputTest.java b/src/test/java/com/kobylynskyi/graphql/codegen/kotlin/GraphQLCodegenRestrictedWordsAndParameterInputTest.java
index 04d6dd345..3d342d680 100644
--- a/src/test/java/com/kobylynskyi/graphql/codegen/kotlin/GraphQLCodegenRestrictedWordsAndParameterInputTest.java
+++ b/src/test/java/com/kobylynskyi/graphql/codegen/kotlin/GraphQLCodegenRestrictedWordsAndParameterInputTest.java
@@ -42,8 +42,9 @@ void generate() throws Exception {
mappingConfig.setApiNameSuffix("API");
mappingConfig.putCustomTypeMappingIfAbsent("DateTime", "java.time.ZonedDateTime");
mappingConfig.setUseObjectMapperForRequestSerialization(singleton("DateTime"));
+
new KotlinGraphQLCodegen(singletonList("src/test/resources/schemas/kt/restricted-words.graphqls"),
- outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo()).generate();
+ outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo(mappingConfig)).generate();
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
List> filters = Arrays
diff --git a/src/test/java/com/kobylynskyi/graphql/codegen/kotlin/GraphQLCodegenSealedInterfacesTest.java b/src/test/java/com/kobylynskyi/graphql/codegen/kotlin/GraphQLCodegenSealedInterfacesTest.java
index 0fb0f4b03..84ffce0c0 100644
--- a/src/test/java/com/kobylynskyi/graphql/codegen/kotlin/GraphQLCodegenSealedInterfacesTest.java
+++ b/src/test/java/com/kobylynskyi/graphql/codegen/kotlin/GraphQLCodegenSealedInterfacesTest.java
@@ -41,7 +41,7 @@ void cleanup() {
@Test
void generate_MultipleInterfacesPerType() throws Exception {
new KotlinGraphQLCodegen(singletonList("src/test/resources/schemas/github.graphqls"),
- outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo()).generate();
+ outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo(mappingConfig)).generate();
File[] files = Objects.requireNonNull(outputScalaClassesDir.listFiles());
assertSameTrimmedContent(new File("src/test/resources/expected-classes/kt/Comment_sealed_interfaces.kt.txt"),
diff --git a/src/test/java/com/kobylynskyi/graphql/codegen/kotlin/GraphQLCodegenTypesAsInterfacesTest.java b/src/test/java/com/kobylynskyi/graphql/codegen/kotlin/GraphQLCodegenTypesAsInterfacesTest.java
index 943935420..cabef34e0 100644
--- a/src/test/java/com/kobylynskyi/graphql/codegen/kotlin/GraphQLCodegenTypesAsInterfacesTest.java
+++ b/src/test/java/com/kobylynskyi/graphql/codegen/kotlin/GraphQLCodegenTypesAsInterfacesTest.java
@@ -9,6 +9,7 @@
import org.junit.jupiter.api.Test;
import java.io.File;
+import java.io.IOException;
import java.util.Collections;
import java.util.HashSet;
import java.util.Objects;
@@ -40,8 +41,7 @@ void cleanup() {
void generate_typesAsInterfaces() throws Exception {
mappingConfig.setTypesAsInterfaces(new HashSet<>(asList("@asInterface", "Order")));
- new KotlinGraphQLCodegen(singletonList("src/test/resources/schemas/types-as-interfaces.graphqls"),
- outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo()).generate();
+ generate("src/test/resources/schemas/types-as-interfaces.graphqls");
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
@@ -61,9 +61,7 @@ void generate_typesAsInterfaces() throws Exception {
void generate_typesAsInterfacesExtendsInterface() throws Exception {
mappingConfig.setTypesAsInterfaces(new HashSet<>(asList("@asInterface")));
- new KotlinGraphQLCodegen(singletonList("src/test/resources/schemas/" +
- "types-as-interfaces-extends-interface.graphqls"),
- outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo()).generate();
+ generate("src/test/resources/schemas/types-as-interfaces-extends-interface.graphqls");
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
@@ -72,13 +70,18 @@ void generate_typesAsInterfacesExtendsInterface() throws Exception {
assertSameTrimmedContent(new File("src/test/resources/expected-classes/kt/" +
"types-as-interfaces-extends-interface/Profile.kt.txt"), getFileByName(files, "Profile.kt"));
assertSameTrimmedContent(new File("src/test/resources/expected-classes/kt/" +
- "types-as-interfaces-extends-interface/QueryResolver.kt.txt"),
+ "types-as-interfaces-extends-interface/QueryResolver.kt.txt"),
getFileByName(files, "QueryResolver.kt"));
assertSameTrimmedContent(new File("src/test/resources/expected-classes/kt/" +
"types-as-interfaces-extends-interface/User.kt.txt"), getFileByName(files, "User.kt"));
assertSameTrimmedContent(new File("src/test/resources/expected-classes/kt/" +
- "types-as-interfaces-extends-interface/UserCurrentQueryResolver.kt.txt"),
+ "types-as-interfaces-extends-interface/UserCurrentQueryResolver.kt.txt"),
getFileByName(files, "UserCurrentQueryResolver.kt"));
}
+ private void generate(String o) throws IOException {
+ new KotlinGraphQLCodegen(singletonList(o),
+ outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo(mappingConfig)).generate();
+ }
+
}
diff --git a/src/test/java/com/kobylynskyi/graphql/codegen/kotlin/GraphQLCodegenUnionResolverTest.java b/src/test/java/com/kobylynskyi/graphql/codegen/kotlin/GraphQLCodegenUnionResolverTest.java
index efe5fe257..640e89cb9 100644
--- a/src/test/java/com/kobylynskyi/graphql/codegen/kotlin/GraphQLCodegenUnionResolverTest.java
+++ b/src/test/java/com/kobylynskyi/graphql/codegen/kotlin/GraphQLCodegenUnionResolverTest.java
@@ -40,7 +40,8 @@ void cleanup() {
@Test
void generate_CheckFiles_with_model_package() throws Exception {
mappingConfig.setPackageName("com.kobylynskyi.graphql.unionresolver");
- generate("src/test/resources/schemas/union-resolver.graphqls");
+
+ generate();
File outputJavaClassesDir = new File("build/generated/com/kobylynskyi/graphql/unionresolver");
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
@@ -62,7 +63,8 @@ void generate_CheckFiles_with_model_package() throws Exception {
void generate_CheckFiles_without_model_package_and_with_prefix_and_suffix() throws Exception {
mappingConfig.setModelNamePrefix("My");
mappingConfig.setModelNameSuffix("Suffix");
- generate("src/test/resources/schemas/union-resolver.graphqls");
+
+ generate();
File outputJavaClassesDir = new File("build/generated");
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
@@ -81,9 +83,10 @@ void generate_CheckFiles_without_model_package_and_with_prefix_and_suffix() thro
}
}
- private void generate(String path) throws IOException {
- new KotlinGraphQLCodegen(singletonList(path), outputBuildDir, mappingConfig,
- TestUtils.getStaticGeneratedInfo()).generate();
+ private void generate() throws IOException {
+ new KotlinGraphQLCodegen(singletonList("src/test/resources/schemas/union-resolver.graphqls"),
+ outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo(mappingConfig))
+ .generate();
}
}
diff --git a/src/test/java/com/kobylynskyi/graphql/codegen/kotlin/GraphQLCodegenUnionWithEnumTest.java b/src/test/java/com/kobylynskyi/graphql/codegen/kotlin/GraphQLCodegenUnionWithEnumTest.java
index bdd04a8a8..61569f518 100644
--- a/src/test/java/com/kobylynskyi/graphql/codegen/kotlin/GraphQLCodegenUnionWithEnumTest.java
+++ b/src/test/java/com/kobylynskyi/graphql/codegen/kotlin/GraphQLCodegenUnionWithEnumTest.java
@@ -34,8 +34,9 @@ void cleanup() {
void generate_CheckFiles() throws Exception {
mappingConfig.setGeneratedLanguage(GeneratedLanguage.KOTLIN);
mappingConfig.setPackageName("com.kobylynskyi.graphql.enumunion");
+
new JavaGraphQLCodegen(singletonList("src/test/resources/schemas/union-with-enum.graphqls"),
- outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo())
+ outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo(mappingConfig))
.generate();
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
diff --git a/src/test/java/com/kobylynskyi/graphql/codegen/model/MappingConfigTest.java b/src/test/java/com/kobylynskyi/graphql/codegen/model/MappingConfigTest.java
index 4afc8adc5..46b2452c6 100644
--- a/src/test/java/com/kobylynskyi/graphql/codegen/model/MappingConfigTest.java
+++ b/src/test/java/com/kobylynskyi/graphql/codegen/model/MappingConfigTest.java
@@ -58,6 +58,7 @@ private static MappingConfig buildMappingConfig() {
config.setGenerateModelsForRootTypes(false);
config.setGenerateApisWithThrowsException(true);
config.setAddGeneratedAnnotation(true);
+ config.setGeneratedAnnotation("jakarta.annotation.Generated");
config.setParametrizedInputSuffix("9");
config.setTypeResolverPrefix("11");
config.setTypeResolverSuffix("12");
@@ -104,6 +105,7 @@ private static MappingConfig buildMappingConfig2() {
config.setGenerateModelsForRootTypes(true);
config.setGenerateApisWithThrowsException(false);
config.setAddGeneratedAnnotation(false);
+ config.setGeneratedAnnotation("javax.annotation.Generated");
config.setParametrizedInputSuffix("99");
config.setTypeResolverPrefix("1111");
config.setTypeResolverSuffix("1212");
@@ -227,6 +229,7 @@ void combineDefaultWithCustom() {
assertFalse(mappingConfig.getGenerateModelsForRootTypes());
assertTrue(mappingConfig.getGenerateApisWithThrowsException());
assertTrue(mappingConfig.getAddGeneratedAnnotation());
+ assertEquals("jakarta.annotation.Generated", mappingConfig.getGeneratedAnnotation());
assertEquals("11", mappingConfig.getTypeResolverPrefix());
assertEquals("12", mappingConfig.getTypeResolverSuffix());
assertEquals("key", mappingConfig.getRelayConfig().getDirectiveArgumentName());
@@ -272,6 +275,7 @@ void combineCustomWithDefault() {
assertFalse(mappingConfig.getGenerateModelsForRootTypes());
assertTrue(mappingConfig.getGenerateApisWithThrowsException());
assertTrue(mappingConfig.getAddGeneratedAnnotation());
+ assertEquals("jakarta.annotation.Generated", mappingConfig.getGeneratedAnnotation());
assertEquals("9", mappingConfig.getParametrizedInputSuffix());
assertEquals("11", mappingConfig.getTypeResolverPrefix());
assertEquals("12", mappingConfig.getTypeResolverSuffix());
@@ -323,6 +327,7 @@ void combineCustomWithCustom() {
assertTrue(mappingConfig.getGenerateModelsForRootTypes());
assertFalse(mappingConfig.getGenerateApisWithThrowsException());
assertFalse(mappingConfig.getAddGeneratedAnnotation());
+ assertEquals("javax.annotation.Generated", mappingConfig.getGeneratedAnnotation());
assertEquals("99", mappingConfig.getParametrizedInputSuffix());
assertEquals("1111", mappingConfig.getTypeResolverPrefix());
assertEquals("1212", mappingConfig.getTypeResolverSuffix());
diff --git a/src/test/java/com/kobylynskyi/graphql/codegen/scala/GraphQLCodegenAnnotationsTest.java b/src/test/java/com/kobylynskyi/graphql/codegen/scala/GraphQLCodegenAnnotationsTest.java
index 7fe7db10b..76e52ce55 100644
--- a/src/test/java/com/kobylynskyi/graphql/codegen/scala/GraphQLCodegenAnnotationsTest.java
+++ b/src/test/java/com/kobylynskyi/graphql/codegen/scala/GraphQLCodegenAnnotationsTest.java
@@ -9,6 +9,7 @@
import org.junit.jupiter.api.Test;
import java.io.File;
+import java.io.IOException;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
@@ -52,8 +53,7 @@ void generate_CustomAnnotationMappings() throws Exception {
" classOf[com.example.json" +
".DateTimeScalarDeserializer])"))));
- new ScalaGraphQLCodegen(singletonList("src/test/resources/schemas/test.graphqls"),
- outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo()).generate();
+ generate("src/test/resources/schemas/test.graphqls");
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
assertFileContainsElements(files, "Event.scala",
@@ -85,8 +85,7 @@ void generate_CustomAnnotationMappings_Class() throws Exception {
"classOf[DeploymentOrderFieldDeserializer])"));
mappingConfig.setCustomAnnotationsMapping(customAnnotationsMapping);
- new ScalaGraphQLCodegen(singletonList("src/test/resources/schemas/github.graphqls"),
- outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo()).generate();
+ generate("src/test/resources/schemas/github.graphqls");
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
assertFileContainsElements(files, "AcceptTopicSuggestionInput.scala",
@@ -122,8 +121,7 @@ void generate_CustomAnnotationMappings_Multiple() throws Exception {
+ ".external.starwars.AcceptTopicSuggestionPayloadTypeResolver])"));
mappingConfig.setCustomAnnotationsMapping(customAnnotationsMapping);
- new ScalaGraphQLCodegen(singletonList("src/test/resources/schemas/github.graphqls"),
- outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo()).generate();
+ generate("src/test/resources/schemas/github.graphqls");
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
assertFileContainsElements(files, "AcceptTopicSuggestionPayload.scala",
@@ -149,8 +147,7 @@ void generate_CustomAnnotationMappings_RequestResponseClasses() throws Exception
mappingConfig.setCustomAnnotationsMapping(customAnnotationsMapping);
mappingConfig.setGenerateClient(true);
- new ScalaGraphQLCodegen(singletonList("src/test/resources/schemas/github.graphqls"),
- outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo()).generate();
+ generate("src/test/resources/schemas/github.graphqls");
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
assertFileContainsElements(files, "CodeOfConductQueryRequest.scala",
@@ -176,8 +173,7 @@ void generate_Directives() throws Exception {
singletonList("@com.example.Relationship(type = {{type}}, direction = {{direction}})"));
mappingConfig.setDirectiveAnnotationsMapping(directiveAnnotationsMapping);
- new ScalaGraphQLCodegen(singletonList("src/test/resources/schemas/test.graphqls"),
- outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo()).generate();
+ generate("src/test/resources/schemas/test.graphqls");
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
assertSameTrimmedContent(
@@ -191,4 +187,9 @@ void generate_Directives() throws Exception {
getFileByName(files, "User.scala"));
}
+ private void generate(String path) throws IOException {
+ new ScalaGraphQLCodegen(singletonList(path), outputBuildDir, mappingConfig,
+ TestUtils.getStaticGeneratedInfo(mappingConfig)).generate();
+ }
+
}
diff --git a/src/test/java/com/kobylynskyi/graphql/codegen/scala/GraphQLCodegenCustomScalarMappingTest.java b/src/test/java/com/kobylynskyi/graphql/codegen/scala/GraphQLCodegenCustomScalarMappingTest.java
index edfd19d0d..e62d04e98 100644
--- a/src/test/java/com/kobylynskyi/graphql/codegen/scala/GraphQLCodegenCustomScalarMappingTest.java
+++ b/src/test/java/com/kobylynskyi/graphql/codegen/scala/GraphQLCodegenCustomScalarMappingTest.java
@@ -9,6 +9,7 @@
import org.junit.jupiter.api.Test;
import java.io.File;
+import java.io.IOException;
import java.util.HashMap;
import java.util.Objects;
@@ -43,8 +44,7 @@ void cleanup() {
void generate_CustomTypeMapping_WholeScalar() throws Exception {
mappingConfig.setCustomTypesMapping(new HashMap<>(singletonMap("ZonedDateTime", "String")));
- new ScalaGraphQLCodegen(singletonList("src/test/resources/schemas/date-scalar.graphqls"),
- outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo()).generate();
+ generate();
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
@@ -61,8 +61,7 @@ void generate_CustomTypeMapping_ScalarOnQueryOnly() throws Exception {
customTypesMapping.put("ZonedDateTime", "java.time.ZonedDateTime");
mappingConfig.setCustomTypesMapping(customTypesMapping);
- new ScalaGraphQLCodegen(singletonList("src/test/resources/schemas/date-scalar.graphqls"),
- outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo()).generate();
+ generate();
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
@@ -81,8 +80,8 @@ void generate_UseObjectMapperToSerializeFields_Parameter() throws Exception {
customTypesMapping.put("ZonedDateTime", "java.time.ZonedDateTime");
mappingConfig.setCustomTypesMapping(customTypesMapping);
mappingConfig.setUseObjectMapperForRequestSerialization(singleton("ZonedDateTime"));
- new ScalaGraphQLCodegen(singletonList("src/test/resources/schemas/date-scalar.graphqls"),
- outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo()).generate();
+
+ generate();
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
@@ -91,4 +90,9 @@ void generate_UseObjectMapperToSerializeFields_Parameter() throws Exception {
"QueryINeedQueryRequest_custom_serializer.scala.txt"),
getFileByName(files, "QueryINeedQueryRequest.scala"));
}
+
+ private void generate() throws IOException {
+ new ScalaGraphQLCodegen(singletonList("src/test/resources/schemas/date-scalar.graphqls"),
+ outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo(mappingConfig)).generate();
+ }
}
diff --git a/src/test/java/com/kobylynskyi/graphql/codegen/scala/GraphQLCodegenDeprecatedTest.java b/src/test/java/com/kobylynskyi/graphql/codegen/scala/GraphQLCodegenDeprecatedTest.java
index 37c0828a8..7a427e1b9 100644
--- a/src/test/java/com/kobylynskyi/graphql/codegen/scala/GraphQLCodegenDeprecatedTest.java
+++ b/src/test/java/com/kobylynskyi/graphql/codegen/scala/GraphQLCodegenDeprecatedTest.java
@@ -40,7 +40,7 @@ void cleanup() {
@Test
void generate_deprecated() throws Exception {
new ScalaGraphQLCodegen(Collections.singletonList("src/test/resources/schemas/deprecated-with-msg.graphqls"),
- outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo()).generate();
+ outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo(mappingConfig)).generate();
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
List generatedFileNames = Arrays.stream(files).map(File::getName).sorted().collect(toList());
diff --git a/src/test/java/com/kobylynskyi/graphql/codegen/scala/GraphQLCodegenEmptyTest.java b/src/test/java/com/kobylynskyi/graphql/codegen/scala/GraphQLCodegenEmptyTest.java
index e23c86c10..c76ac12b0 100644
--- a/src/test/java/com/kobylynskyi/graphql/codegen/scala/GraphQLCodegenEmptyTest.java
+++ b/src/test/java/com/kobylynskyi/graphql/codegen/scala/GraphQLCodegenEmptyTest.java
@@ -44,7 +44,7 @@ void cleanup() {
@Test
void generateServerSideClasses() throws Exception {
new ScalaGraphQLCodegen(schemaFinder.findSchemas(), outputBuildDir, mappingConfig,
- TestUtils.getStaticGeneratedInfo()).generate();
+ TestUtils.getStaticGeneratedInfo(mappingConfig)).generate();
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
Set generatedFileNames = Arrays.stream(files).map(File::getName).collect(toSet());
@@ -64,8 +64,9 @@ void generateServerSideClasses() throws Exception {
void generateClientSideClasses() throws Exception {
mappingConfig.setGenerateApis(false);
mappingConfig.setGenerateClient(true);
+
new JavaGraphQLCodegen(schemaFinder.findSchemas(), outputBuildDir, mappingConfig,
- TestUtils.getStaticGeneratedInfo()).generate();
+ TestUtils.getStaticGeneratedInfo(mappingConfig)).generate();
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
diff --git a/src/test/java/com/kobylynskyi/graphql/codegen/scala/GraphQLCodegenExtendTest.java b/src/test/java/com/kobylynskyi/graphql/codegen/scala/GraphQLCodegenExtendTest.java
index cad60cdf5..26bc33075 100644
--- a/src/test/java/com/kobylynskyi/graphql/codegen/scala/GraphQLCodegenExtendTest.java
+++ b/src/test/java/com/kobylynskyi/graphql/codegen/scala/GraphQLCodegenExtendTest.java
@@ -10,6 +10,7 @@
import org.junit.jupiter.api.Test;
import java.io.File;
+import java.io.IOException;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.HashMap;
@@ -44,8 +45,7 @@ void cleanup() {
@Test
void generateServerSideClasses() throws Exception {
- new ScalaGraphQLCodegen(schemaFinder.findSchemas(), outputBuildDir, mappingConfig,
- TestUtils.getStaticGeneratedInfo()).generate();
+ generate();
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
Set generatedFileNames = Arrays.stream(files).map(File::getName).collect(toSet());
@@ -66,8 +66,8 @@ void generateServerSideClasses() throws Exception {
void generateServerSideClasses_ExtensionFieldsResolvers_WithExclusions() throws Exception {
mappingConfig.setGenerateExtensionFieldsResolvers(true);
mappingConfig.setFieldsWithoutResolvers(new HashSet<>(asList("Node", "Event.assets")));
- new ScalaGraphQLCodegen(schemaFinder.findSchemas(), outputBuildDir, mappingConfig,
- TestUtils.getStaticGeneratedInfo()).generate();
+
+ generate();
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
Set generatedFileNames = Arrays.stream(files).map(File::getName).collect(toSet());
@@ -88,8 +88,8 @@ void generateServerSideClasses_ExtensionFieldsResolvers_WithExclusions() throws
@Test
void generateServerSideClasses_EmptyTypes() throws Exception {
schemaFinder.setIncludePattern("empty-types-with-extend\\.graphqls");
- new ScalaGraphQLCodegen(schemaFinder.findSchemas(), outputBuildDir, mappingConfig,
- TestUtils.getStaticGeneratedInfo()).generate();
+
+ generate();
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
Set generatedFileNames = Arrays.stream(files).map(File::getName).collect(toSet());
@@ -110,8 +110,8 @@ void generateServerSideClasses_EmptyTypes() throws Exception {
void generateClientSideClasses() throws Exception {
mappingConfig.setGenerateApis(false);
mappingConfig.setGenerateClient(true);
- new ScalaGraphQLCodegen(schemaFinder.findSchemas(), outputBuildDir, mappingConfig,
- TestUtils.getStaticGeneratedInfo()).generate();
+
+ generate();
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
@@ -129,8 +129,8 @@ void generatePrimitiveTypesResponseResolverClasses() throws Exception {
mappingConfig.setGenerateApis(true);
mappingConfig.setGenerateClient(true);
schemaFinder.setIncludePattern("null-extend1.graphqls");
- new ScalaGraphQLCodegen(schemaFinder.findSchemas(), outputBuildDir, mappingConfig,
- TestUtils.getStaticGeneratedInfo()).generate();
+
+ generate();
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
@@ -164,8 +164,8 @@ void generatePrimitiveTypesResponseResolverClasses_With_SetUseOptionalForNullabl
// is mandatory.
mappingConfig.setUseOptionalForNullableReturnTypes(true);
schemaFinder.setIncludePattern("null-extend2.graphqls");
- new ScalaGraphQLCodegen(schemaFinder.findSchemas(), outputBuildDir, mappingConfig,
- TestUtils.getStaticGeneratedInfo()).generate();
+
+ generate();
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
@@ -184,8 +184,8 @@ void generatePrimitiveTypesResponseResolverClasses_Without_SetUseOptionalForNull
mappingConfig.setGenerateClient(true);
mappingConfig.setUseOptionalForNullableReturnTypes(false);
schemaFinder.setIncludePattern("null-extend2.graphqls");
- new ScalaGraphQLCodegen(schemaFinder.findSchemas(), outputBuildDir, mappingConfig,
- TestUtils.getStaticGeneratedInfo()).generate();
+
+ generate();
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
//Therefore, when the return type is a primitive type, the return option is automatically turned on, and this
@@ -212,8 +212,8 @@ void generatePrimitiveTypesResponseResolverClasses_nullable() throws Exception {
mappingConfig.setGenerateClient(true);
mappingConfig.setUseOptionalForNullableReturnTypes(true);
schemaFinder.setIncludePattern("null-extend3.graphqls");
- new ScalaGraphQLCodegen(schemaFinder.findSchemas(), outputBuildDir, mappingConfig,
- TestUtils.getStaticGeneratedInfo()).generate();
+
+ generate();
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
@@ -252,9 +252,7 @@ void generate_OptionalFieldInInterfaceAndMandatoryInType() throws Exception {
mappingConfig.setCustomTypesMapping(maps);
schemaFinder.setIncludePattern("optional-vs-mandatory-types.graphqls");
- new ScalaGraphQLCodegen(schemaFinder.findSchemas(), outputBuildDir, mappingConfig,
- TestUtils.getStaticGeneratedInfo())
- .generate();
+ generate();
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
@@ -265,4 +263,10 @@ void generate_OptionalFieldInInterfaceAndMandatoryInType() throws Exception {
new File("src/test/resources/expected-classes/scala/optional/TypeWithMandatoryField.scala.txt"),
getFileByName(files, "TypeWithMandatoryField.scala"));
}
+
+ private void generate() throws IOException {
+ new ScalaGraphQLCodegen(schemaFinder.findSchemas(), outputBuildDir, mappingConfig,
+ TestUtils.getStaticGeneratedInfo(mappingConfig))
+ .generate();
+ }
}
\ No newline at end of file
diff --git a/src/test/java/com/kobylynskyi/graphql/codegen/scala/GraphQLCodegenGitHubTest.java b/src/test/java/com/kobylynskyi/graphql/codegen/scala/GraphQLCodegenGitHubTest.java
index 4d8f9cdef..e5a9c91fa 100644
--- a/src/test/java/com/kobylynskyi/graphql/codegen/scala/GraphQLCodegenGitHubTest.java
+++ b/src/test/java/com/kobylynskyi/graphql/codegen/scala/GraphQLCodegenGitHubTest.java
@@ -49,8 +49,8 @@ void generate_MultipleInterfacesPerType() throws Exception {
mappingConfig.putCustomTypeMappingIfAbsent("Int!", "Int");
mappingConfig.putCustomTypeMappingIfAbsent("Boolean!", "Boolean");
- new ScalaGraphQLCodegen(singletonList("src/test/resources/schemas/github.graphqls"),
- outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo()).generate();
+ generate("src/test/resources/schemas/github.graphqls");
+
File[] files = Objects.requireNonNull(outputScalaClassesDir.listFiles());
assertSameTrimmedContent(new File("src/test/resources/expected-classes/scala/Commit.scala.txt"),
@@ -65,8 +65,7 @@ void generate_ClassNameWithSuffix_Prefix() throws Exception {
mappingConfig.setModelNamePrefix("Github");
mappingConfig.setModelNameSuffix("TO");
- new ScalaGraphQLCodegen(singletonList("src/test/resources/schemas/github.graphqls"),
- outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo()).generate();
+ generate("src/test/resources/schemas/github.graphqls");
File[] files = Objects.requireNonNull(outputScalaClassesDir.listFiles());
@@ -96,8 +95,7 @@ void generate_ClassNameWithSuffix_Prefix() throws Exception {
void generate_NoValidationAnnotation() throws Exception {
mappingConfig.setModelValidationAnnotation("");
- new ScalaGraphQLCodegen(singletonList("src/test/resources/schemas/github.graphqls"),
- outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo()).generate();
+ generate("src/test/resources/schemas/github.graphqls");
File commitFile = getFileByName(Objects.requireNonNull(outputScalaClassesDir.listFiles()), "Commit.scala");
assertSameTrimmedContent(
@@ -110,8 +108,7 @@ void generate_Client_ConditionalFragments() throws Exception {
mappingConfig.setGenerateClient(true);
mappingConfig.setGenerateApis(false);
- new ScalaGraphQLCodegen(singletonList("src/test/resources/schemas/github.graphqls"),
- outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo()).generate();
+ generate("src/test/resources/schemas/github.graphqls");
File[] files = Objects.requireNonNull(outputScalaClassesDir.listFiles());
assertSameTrimmedContent(new File(
@@ -130,8 +127,7 @@ void generate_NoPrimitives() throws Exception {
mappingConfig.putCustomTypeMappingIfAbsent("Boolean!", "java.lang.Boolean");
mappingConfig.setUseOptionalForNullableReturnTypes(true);
- new ScalaGraphQLCodegen(singletonList("src/test/resources/schemas/github.graphqls"),
- outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo()).generate();
+ generate("src/test/resources/schemas/github.graphqls");
File[] files = Objects.requireNonNull(outputScalaClassesDir.listFiles());
assertSameTrimmedContent(
@@ -146,8 +142,7 @@ void generate_Primitives() throws Exception {
mappingConfig.putCustomTypeMappingIfAbsent("Boolean!", "Boolean");
mappingConfig.setUseOptionalForNullableReturnTypes(true);
- new ScalaGraphQLCodegen(singletonList("src/test/resources/schemas/github.graphqls"),
- outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo()).generate();
+ generate("src/test/resources/schemas/github.graphqls");
File[] files = Objects.requireNonNull(outputScalaClassesDir.listFiles());
assertSameTrimmedContent(new File("src/test/resources/expected-classes/scala/Commit_withPrimitives.scala.txt"),
@@ -158,8 +153,8 @@ void generate_Primitives() throws Exception {
void generate_ResponseWithPrimitiveType() throws Exception {
mappingConfig.putCustomTypeMappingIfAbsent("Int!", "Int");
mappingConfig.putCustomTypeMappingIfAbsent("Int", "Int");
- new ScalaGraphQLCodegen(singletonList("src/test/resources/schemas/primitive-query-response-type.graphqls"),
- outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo()).generate();
+
+ generate("src/test/resources/schemas/primitive-query-response-type.graphqls");
File[] files = Objects.requireNonNull(outputScalaClassesDir.listFiles());
@@ -170,8 +165,7 @@ void generate_ResponseWithPrimitiveType() throws Exception {
@Test
void generate_ScalaList() throws Exception {
- new ScalaGraphQLCodegen(singletonList("src/test/resources/schemas/github.graphqls"),
- outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo()).generate();
+ generate("src/test/resources/schemas/github.graphqls");
File[] files = Objects.requireNonNull(outputScalaClassesDir.listFiles());
assertSameTrimmedContent(
@@ -199,13 +193,18 @@ void generate_ScalaList() throws Exception {
void generate_Var_Field() throws Exception {
mappingConfig.setGenerateImmutableModels(false);
- new ScalaGraphQLCodegen(singletonList("src/test/resources/schemas/github.graphqls"),
- outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo()).generate();
+ generate("src/test/resources/schemas/github.graphqls");
File[] files = Objects.requireNonNull(outputScalaClassesDir.listFiles());
assertSameTrimmedContent(new File("src/test/resources/expected-classes/scala/Commit_Var_Field.scala.txt"),
getFileByName(files, "Commit.scala"));
}
+ private void generate(String path) throws IOException {
+ new ScalaGraphQLCodegen(singletonList(path),
+ outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo(mappingConfig))
+ .generate();
+ }
+
}
\ No newline at end of file
diff --git a/src/test/java/com/kobylynskyi/graphql/codegen/scala/GraphQLCodegenOpenclassesTest.java b/src/test/java/com/kobylynskyi/graphql/codegen/scala/GraphQLCodegenOpenclassesTest.java
index 8cb512b0a..189592f84 100644
--- a/src/test/java/com/kobylynskyi/graphql/codegen/scala/GraphQLCodegenOpenclassesTest.java
+++ b/src/test/java/com/kobylynskyi/graphql/codegen/scala/GraphQLCodegenOpenclassesTest.java
@@ -9,6 +9,7 @@
import org.junit.jupiter.api.Test;
import java.io.File;
+import java.io.IOException;
import java.util.Objects;
import static com.kobylynskyi.graphql.codegen.TestUtils.assertSameTrimmedContent;
@@ -41,8 +42,8 @@ void cleanup() {
@Test
void generate_MultipleInterfacesPerType() throws Exception {
- new ScalaGraphQLCodegen(singletonList("src/test/resources/schemas/github.graphqls"),
- outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo()).generate();
+ generate();
+
File[] files = Objects.requireNonNull(outputScalaClassesDir.listFiles());
assertSameTrimmedContent(
@@ -53,12 +54,18 @@ void generate_MultipleInterfacesPerType() throws Exception {
@Test
void generate_MultipleInterfacesPerTypeVarFields() throws Exception {
mappingConfig.setGenerateImmutableModels(false);
- new ScalaGraphQLCodegen(singletonList("src/test/resources/schemas/github.graphqls"),
- outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo()).generate();
+
+ generate();
+
File[] files = Objects.requireNonNull(outputScalaClassesDir.listFiles());
assertSameTrimmedContent(
new File("src/test/resources/expected-classes/scala/Commit_normal_class_var_fields.scala.txt"),
getFileByName(files, "Commit.scala"));
}
+
+ private void generate() throws IOException {
+ new ScalaGraphQLCodegen(singletonList("src/test/resources/schemas/github.graphqls"),
+ outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo(mappingConfig)).generate();
+ }
}
\ No newline at end of file
diff --git a/src/test/java/com/kobylynskyi/graphql/codegen/scala/GraphQLCodegenRelayTest.java b/src/test/java/com/kobylynskyi/graphql/codegen/scala/GraphQLCodegenRelayTest.java
index d2dd0c9aa..e5ef6e37b 100644
--- a/src/test/java/com/kobylynskyi/graphql/codegen/scala/GraphQLCodegenRelayTest.java
+++ b/src/test/java/com/kobylynskyi/graphql/codegen/scala/GraphQLCodegenRelayTest.java
@@ -10,6 +10,7 @@
import org.junit.jupiter.api.Test;
import java.io.File;
+import java.io.IOException;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.HashSet;
@@ -43,8 +44,7 @@ void cleanup() {
@Test
void generateServerSideRelayClasses() throws Exception {
- new ScalaGraphQLCodegen(schemaFinder.findSchemas(), outputBuildDir, mappingConfig,
- TestUtils.getStaticGeneratedInfo()).generate();
+ generate();
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
Set generatedFileNames = Arrays.stream(files).map(File::getName).collect(toSet());
@@ -62,8 +62,8 @@ void generateServerSideRelayClasses() throws Exception {
void generateServerSideRelayClasses_CustomGenericsConnectionType() throws Exception {
mappingConfig.getRelayConfig()
.setConnectionType("reactor.core.publisher.Mono[graphql.relay.Connection[%s]]");
- new ScalaGraphQLCodegen(schemaFinder.findSchemas(), outputBuildDir, mappingConfig,
- TestUtils.getStaticGeneratedInfo()).generate();
+
+ generate();
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
@@ -73,4 +73,9 @@ void generateServerSideRelayClasses_CustomGenericsConnectionType() throws Except
}
+ private void generate() throws IOException {
+ new ScalaGraphQLCodegen(schemaFinder.findSchemas(), outputBuildDir, mappingConfig,
+ TestUtils.getStaticGeneratedInfo(mappingConfig)).generate();
+ }
+
}
\ No newline at end of file
diff --git a/src/test/java/com/kobylynskyi/graphql/codegen/scala/GraphQLCodegenRestrictedWordsAndToStringTest.java b/src/test/java/com/kobylynskyi/graphql/codegen/scala/GraphQLCodegenRestrictedWordsAndToStringTest.java
index 8c2f04dc7..4d6a9b2e8 100644
--- a/src/test/java/com/kobylynskyi/graphql/codegen/scala/GraphQLCodegenRestrictedWordsAndToStringTest.java
+++ b/src/test/java/com/kobylynskyi/graphql/codegen/scala/GraphQLCodegenRestrictedWordsAndToStringTest.java
@@ -9,6 +9,7 @@
import org.junit.jupiter.api.Test;
import java.io.File;
+import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
@@ -26,27 +27,27 @@ class GraphQLCodegenRestrictedWordsAndToStringTest {
private final File outputBuildDir = new File("build/generated");
private final File outputJavaClassesDir = new File("build/generated/com/kobylynskyi/graphql/codegen/prot");
- @AfterEach
- void cleanup() {
- Utils.deleteDir(outputBuildDir);
- }
-
@BeforeEach
public void setup() {
mappingConfig.setGeneratedLanguage(GeneratedLanguage.SCALA);
+ mappingConfig.setPackageName("com.kobylynskyi.graphql.codegen.prot");
+ mappingConfig.setGenerateEqualsAndHashCode(true);
+ mappingConfig.setGenerateModelsForRootTypes(true);
+ mappingConfig.setApiNameSuffix("API");
+ }
+
+ @AfterEach
+ void cleanup() {
+ Utils.deleteDir(outputBuildDir);
}
@Test
void generate_SetGenerateBuilder_False() throws Exception {
- mappingConfig.setPackageName("com.kobylynskyi.graphql.codegen.prot");
// fix an issue when generateBuilder=false => can not use object.OPERATION_NAME
mappingConfig.setGenerateBuilder(false);
- mappingConfig.setGenerateEqualsAndHashCode(true);
mappingConfig.setGenerateClient(true);
- mappingConfig.setGenerateModelsForRootTypes(true);
- mappingConfig.setApiNameSuffix("API");
- new ScalaGraphQLCodegen(singletonList("src/test/resources/schemas/scala/restricted-words.graphqls"),
- outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo()).generate();
+
+ generate();
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
List generatedFileNames = Arrays.stream(files).map(File::getName)
@@ -64,22 +65,19 @@ void generate_SetGenerateBuilder_False() throws Exception {
@Test
void generate_SetGenerateClient_True() throws Exception {
- mappingConfig.setPackageName("com.kobylynskyi.graphql.codegen.prot");
- mappingConfig.setGenerateEqualsAndHashCode(true);
mappingConfig.setGenerateClient(true);
mappingConfig.setGenerateBuilder(true);
mappingConfig.setUseObjectMapperForRequestSerialization(singleton("TestEnum"));
mappingConfig.putCustomTypeMappingIfAbsent("DateTime", "java.time.ZonedDateTime");
mappingConfig.setGenerateApis(true);
- mappingConfig.setGenerateModelsForRootTypes(true);
- mappingConfig.setApiNameSuffix("API");
mappingConfig.setUseObjectMapperForRequestSerialization(singleton("DateTime"));
- new ScalaGraphQLCodegen(singletonList("src/test/resources/schemas/scala/restricted-words.graphqls"),
- outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo()).generate();
+
+ generate();
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
- List generatedFileNames = Arrays.stream(files).map(File::getName).filter(
- f -> Arrays.asList("QueryPrivateParametrizedInput.scala", "Synchronized.scala").contains(f)).sorted()
+ List generatedFileNames = Arrays.stream(files).map(File::getName)
+ .filter(f -> Arrays.asList("QueryPrivateParametrizedInput.scala", "Synchronized.scala").contains(f))
+ .sorted()
.collect(toList());
assertEquals(Arrays.asList("QueryPrivateParametrizedInput.scala", "Synchronized.scala"), generatedFileNames);
@@ -95,18 +93,13 @@ void generate_SetGenerateClient_True() throws Exception {
@Test
void generate_SetGenerateClient_False() throws Exception {
- mappingConfig.setPackageName("com.kobylynskyi.graphql.codegen.prot");
- mappingConfig.setGenerateEqualsAndHashCode(true);
mappingConfig.setGenerateClient(false);
mappingConfig.setGenerateToString(true);
mappingConfig.setUseObjectMapperForRequestSerialization(singleton("TestEnum"));
mappingConfig.putCustomTypeMappingIfAbsent("DateTime", "java.time.ZonedDateTime");
mappingConfig.setGenerateApis(true);
- mappingConfig.setGenerateModelsForRootTypes(true);
- mappingConfig.setApiNameSuffix("API");
- new ScalaGraphQLCodegen(singletonList("src/test/resources/schemas/scala/restricted-words.graphqls"),
- outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo()).generate();
+ generate();
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
List generatedFileNames = Arrays.stream(files).map(File::getName)
@@ -126,4 +119,9 @@ void generate_SetGenerateClient_False() throws Exception {
}
}
+ private void generate() throws IOException {
+ new ScalaGraphQLCodegen(singletonList("src/test/resources/schemas/scala/restricted-words.graphqls"),
+ outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo(mappingConfig)).generate();
+ }
+
}
diff --git a/src/test/java/com/kobylynskyi/graphql/codegen/scala/GraphQLCodegenTypesAsInterfacesTest.java b/src/test/java/com/kobylynskyi/graphql/codegen/scala/GraphQLCodegenTypesAsInterfacesTest.java
index 5461f6152..dd63b7749 100644
--- a/src/test/java/com/kobylynskyi/graphql/codegen/scala/GraphQLCodegenTypesAsInterfacesTest.java
+++ b/src/test/java/com/kobylynskyi/graphql/codegen/scala/GraphQLCodegenTypesAsInterfacesTest.java
@@ -9,6 +9,7 @@
import org.junit.jupiter.api.Test;
import java.io.File;
+import java.io.IOException;
import java.util.Collections;
import java.util.HashSet;
import java.util.Objects;
@@ -40,8 +41,7 @@ void cleanup() {
void generate_typeAsInterface() throws Exception {
mappingConfig.setTypesAsInterfaces(new HashSet<>(asList("@asInterface", "Order")));
- new ScalaGraphQLCodegen(singletonList("src/test/resources/schemas/types-as-interfaces.graphqls"),
- outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo()).generate();
+ generate("src/test/resources/schemas/types-as-interfaces.graphqls");
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
@@ -61,25 +61,29 @@ void generate_typeAsInterface() throws Exception {
void generate_typeAsInterfaceExtendsInterface() throws Exception {
mappingConfig.setTypesAsInterfaces(new HashSet<>(asList("@asInterface")));
- new ScalaGraphQLCodegen(singletonList("src/test/resources/schemas/" +
- "types-as-interfaces-extends-interface.graphqls"),
- outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo()).generate();
+ generate("src/test/resources/schemas/types-as-interfaces-extends-interface.graphqls");
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
assertSameTrimmedContent(new File("src/test/resources/expected-classes/scala/" +
"types-as-interfaces-extends-interface/Node.scala.txt"), getFileByName(files, "Node.scala"));
assertSameTrimmedContent(new File("src/test/resources/expected-classes/scala/" +
- "types-as-interfaces-extends-interface/Profile.scala.txt"),
+ "types-as-interfaces-extends-interface/Profile.scala.txt"),
getFileByName(files, "Profile.scala"));
assertSameTrimmedContent(new File("src/test/resources/expected-classes/scala/" +
- "types-as-interfaces-extends-interface/QueryResolver.scala.txt"),
+ "types-as-interfaces-extends-interface/QueryResolver.scala.txt"),
getFileByName(files, "QueryResolver.scala"));
assertSameTrimmedContent(new File("src/test/resources/expected-classes/scala/" +
"types-as-interfaces-extends-interface/User.scala.txt"), getFileByName(files, "User.scala"));
assertSameTrimmedContent(new File("src/test/resources/expected-classes/scala/" +
- "types-as-interfaces-extends-interface/UserCurrentQueryResolver.scala.txt"),
+ "types-as-interfaces-extends-interface/UserCurrentQueryResolver.scala.txt"),
getFileByName(files, "UserCurrentQueryResolver.scala"));
}
+ private void generate(String path) throws IOException {
+ new ScalaGraphQLCodegen(singletonList(path),
+ outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo(mappingConfig))
+ .generate();
+ }
+
}
diff --git a/src/test/java/com/kobylynskyi/graphql/codegen/scala/GraphQLCodegenUnionResolverTest.java b/src/test/java/com/kobylynskyi/graphql/codegen/scala/GraphQLCodegenUnionResolverTest.java
index 1efa8b065..83ba98e57 100644
--- a/src/test/java/com/kobylynskyi/graphql/codegen/scala/GraphQLCodegenUnionResolverTest.java
+++ b/src/test/java/com/kobylynskyi/graphql/codegen/scala/GraphQLCodegenUnionResolverTest.java
@@ -40,7 +40,8 @@ void cleanup() {
@Test
void generate_CheckFiles_with_model_package() throws Exception {
mappingConfig.setPackageName("com.kobylynskyi.graphql.unionresolver");
- generate("src/test/resources/schemas/union-resolver.graphqls");
+
+ generate();
File outputJavaClassesDir = new File("build/generated/com/kobylynskyi/graphql/unionresolver");
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
@@ -62,7 +63,8 @@ void generate_CheckFiles_with_model_package() throws Exception {
void generate_CheckFiles_without_model_package_and_with_prefix_and_suffix() throws Exception {
mappingConfig.setModelNamePrefix("My");
mappingConfig.setModelNameSuffix("Suffix");
- generate("src/test/resources/schemas/union-resolver.graphqls");
+
+ generate();
File outputJavaClassesDir = new File("build/generated");
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
@@ -81,9 +83,10 @@ void generate_CheckFiles_without_model_package_and_with_prefix_and_suffix() thro
}
}
- private void generate(String path) throws IOException {
- new ScalaGraphQLCodegen(singletonList(path), outputBuildDir, mappingConfig,
- TestUtils.getStaticGeneratedInfo()).generate();
+ private void generate() throws IOException {
+ new ScalaGraphQLCodegen(singletonList("src/test/resources/schemas/union-resolver.graphqls"),
+ outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo(mappingConfig))
+ .generate();
}
}
From 11c9d5bcd740022a66ff9066b78af88e625921e8 Mon Sep 17 00:00:00 2001
From: Bogdan Kobylynskyi <92bogdan@gmail.com>
Date: Sun, 26 Feb 2023 07:27:12 -0500
Subject: [PATCH 09/25] Bump version to 5.6.0-SNAPSHOT (#1038)
---
build.gradle | 2 +-
plugins/gradle/example-client-kotlin/build.gradle | 6 +++---
plugins/gradle/example-client/build.gradle | 4 ++--
plugins/gradle/example-server/build.gradle | 2 +-
.../gradle/graphql-java-codegen-gradle-plugin/build.gradle | 2 +-
plugins/maven/example-client/pom.xml | 2 +-
plugins/maven/example-server/pom.xml | 2 +-
plugins/maven/graphql-java-codegen-maven-plugin/pom.xml | 4 ++--
.../example-client-scala/project/plugins.sbt | 2 +-
.../example-client-scala/version.sbt | 2 +-
.../example-client/project/plugins.sbt | 2 +-
.../graphql-codegen-sbt-plugin/example-client/version.sbt | 2 +-
.../graphql-codegen-sbt-plugin/simple/project/plugins.sbt | 2 +-
.../sbt-test/graphql-codegen-sbt-plugin/simple/version.sbt | 2 +-
plugins/sbt/graphql-java-codegen-sbt-plugin/version.sbt | 2 +-
15 files changed, 19 insertions(+), 19 deletions(-)
diff --git a/build.gradle b/build.gradle
index 7b6595024..d539126db 100644
--- a/build.gradle
+++ b/build.gradle
@@ -9,7 +9,7 @@ plugins {
id "org.sonarqube" version "3.2.0"
}
-def graphqlCodegenVersion = '5.5.1-SNAPSHOT' // This variable used in the automatic release process
+def graphqlCodegenVersion = '5.6.0-SNAPSHOT' // This variable used in the automatic release process
group = "io.github.kobylynskyi"
version = graphqlCodegenVersion
diff --git a/plugins/gradle/example-client-kotlin/build.gradle b/plugins/gradle/example-client-kotlin/build.gradle
index 12998fb7a..3d0a3f2b7 100644
--- a/plugins/gradle/example-client-kotlin/build.gradle
+++ b/plugins/gradle/example-client-kotlin/build.gradle
@@ -4,10 +4,10 @@ import io.github.kobylynskyi.graphql.codegen.gradle.GraphQLCodegenGradleTask
plugins {
id "java"
id "org.jetbrains.kotlin.jvm" version "1.6.21"
- id "io.github.kobylynskyi.graphql.codegen" version "5.5.1-SNAPSHOT"
+ id "io.github.kobylynskyi.graphql.codegen" version "5.6.0-SNAPSHOT"
}
-def graphqlCodegenClientKotlinVersion = '5.5.1-SNAPSHOT' // Variable used in the automatic release process
+def graphqlCodegenClientKotlinVersion = '5.6.0-SNAPSHOT' // Variable used in the automatic release process
group = 'io.github.dreamylost'
version = graphqlCodegenClientKotlinVersion
@@ -29,7 +29,7 @@ repositories {
dependencies {
- implementation "io.github.kobylynskyi:graphql-java-codegen:5.5.1-SNAPSHOT"
+ implementation "io.github.kobylynskyi:graphql-java-codegen:5.6.0-SNAPSHOT"
implementation "javax.validation:validation-api:2.0.1.Final"
implementation "com.squareup.okhttp3:okhttp:4.2.2"
implementation "com.fasterxml.jackson.core:jackson-core:2.13.3"
diff --git a/plugins/gradle/example-client/build.gradle b/plugins/gradle/example-client/build.gradle
index f8943b336..24e448c08 100644
--- a/plugins/gradle/example-client/build.gradle
+++ b/plugins/gradle/example-client/build.gradle
@@ -7,7 +7,7 @@ plugins {
// use the latest available version:
// https://plugins.gradle.org/plugin/io.github.kobylynskyi.graphql.codegen
- id "io.github.kobylynskyi.graphql.codegen" version "5.5.1-SNAPSHOT"
+ id "io.github.kobylynskyi.graphql.codegen" version "5.6.0-SNAPSHOT"
}
mainClassName = "io.github.kobylynskyi.order.Application"
@@ -22,7 +22,7 @@ dependencies {
// use the latest available version:
// https://search.maven.org/artifact/io.github.kobylynskyi/graphql-java-codegen
- implementation "io.github.kobylynskyi:graphql-java-codegen:5.5.1-SNAPSHOT"
+ implementation "io.github.kobylynskyi:graphql-java-codegen:5.6.0-SNAPSHOT"
implementation "org.apache.httpcomponents:httpclient:4.5.13"
implementation "javax.validation:validation-api:2.0.1.Final"
diff --git a/plugins/gradle/example-server/build.gradle b/plugins/gradle/example-server/build.gradle
index 6a3922f7a..2b0fed249 100644
--- a/plugins/gradle/example-server/build.gradle
+++ b/plugins/gradle/example-server/build.gradle
@@ -6,7 +6,7 @@ plugins {
//
// use the latest available version:
// https://plugins.gradle.org/plugin/io.github.kobylynskyi.graphql.codegen
- id "io.github.kobylynskyi.graphql.codegen" version "5.5.1-SNAPSHOT"
+ id "io.github.kobylynskyi.graphql.codegen" version "5.6.0-SNAPSHOT"
}
mainClassName = "io.github.kobylynskyi.product.Application"
diff --git a/plugins/gradle/graphql-java-codegen-gradle-plugin/build.gradle b/plugins/gradle/graphql-java-codegen-gradle-plugin/build.gradle
index 751f0f812..c16aae14a 100644
--- a/plugins/gradle/graphql-java-codegen-gradle-plugin/build.gradle
+++ b/plugins/gradle/graphql-java-codegen-gradle-plugin/build.gradle
@@ -16,7 +16,7 @@ apply plugin: "java"
apply plugin: "idea"
apply plugin: "maven-publish"
-def graphqlCodegenGradlePluginVersion = '5.5.1-SNAPSHOT' // This variable used in the automatic release process
+def graphqlCodegenGradlePluginVersion = '5.6.0-SNAPSHOT' // This variable used in the automatic release process
group = "io.github.kobylynskyi"
version = graphqlCodegenGradlePluginVersion
diff --git a/plugins/maven/example-client/pom.xml b/plugins/maven/example-client/pom.xml
index 418c422cb..5d9abe668 100644
--- a/plugins/maven/example-client/pom.xml
+++ b/plugins/maven/example-client/pom.xml
@@ -4,7 +4,7 @@
io.github.kobylynskyi
graphql-codegen-maven-plugin-example-client
- 5.5.1-SNAPSHOT
+ 5.6.0-SNAPSHOT
graphql-codegen-maven-plugin-example-client
diff --git a/plugins/maven/example-server/pom.xml b/plugins/maven/example-server/pom.xml
index 5f5d85d11..fd5470505 100644
--- a/plugins/maven/example-server/pom.xml
+++ b/plugins/maven/example-server/pom.xml
@@ -4,7 +4,7 @@
io.github.kobylynskyi
graphql-codegen-maven-plugin-example-server
- 5.5.1-SNAPSHOT
+ 5.6.0-SNAPSHOT
graphql-codegen-maven-plugin-example-server
diff --git a/plugins/maven/graphql-java-codegen-maven-plugin/pom.xml b/plugins/maven/graphql-java-codegen-maven-plugin/pom.xml
index ba76048c6..645873e44 100644
--- a/plugins/maven/graphql-java-codegen-maven-plugin/pom.xml
+++ b/plugins/maven/graphql-java-codegen-maven-plugin/pom.xml
@@ -3,7 +3,7 @@
io.github.kobylynskyi
graphql-codegen-maven-plugin
- 5.5.1-SNAPSHOT
+ 5.6.0-SNAPSHOT
maven-plugin
graphql-codegen-maven-plugin
@@ -72,7 +72,7 @@
3.0.1
3.3.4
- 5.5.1-SNAPSHOT
+ 5.6.0-SNAPSHOT
diff --git a/plugins/sbt/graphql-java-codegen-sbt-plugin/src/sbt-test/graphql-codegen-sbt-plugin/example-client-scala/project/plugins.sbt b/plugins/sbt/graphql-java-codegen-sbt-plugin/src/sbt-test/graphql-codegen-sbt-plugin/example-client-scala/project/plugins.sbt
index 8b61a3547..4608c8e00 100644
--- a/plugins/sbt/graphql-java-codegen-sbt-plugin/src/sbt-test/graphql-codegen-sbt-plugin/example-client-scala/project/plugins.sbt
+++ b/plugins/sbt/graphql-java-codegen-sbt-plugin/src/sbt-test/graphql-codegen-sbt-plugin/example-client-scala/project/plugins.sbt
@@ -1 +1 @@
-addSbtPlugin("io.github.jxnu-liguobin" % "graphql-codegen-sbt-plugin" % "5.5.1-SNAPSHOT")
+addSbtPlugin("io.github.jxnu-liguobin" % "graphql-codegen-sbt-plugin" % "5.6.0-SNAPSHOT")
diff --git a/plugins/sbt/graphql-java-codegen-sbt-plugin/src/sbt-test/graphql-codegen-sbt-plugin/example-client-scala/version.sbt b/plugins/sbt/graphql-java-codegen-sbt-plugin/src/sbt-test/graphql-codegen-sbt-plugin/example-client-scala/version.sbt
index 4be577733..a761c0701 100644
--- a/plugins/sbt/graphql-java-codegen-sbt-plugin/src/sbt-test/graphql-codegen-sbt-plugin/example-client-scala/version.sbt
+++ b/plugins/sbt/graphql-java-codegen-sbt-plugin/src/sbt-test/graphql-codegen-sbt-plugin/example-client-scala/version.sbt
@@ -1 +1 @@
-version in ThisBuild := "5.5.1-SNAPSHOT"
+version in ThisBuild := "5.6.0-SNAPSHOT"
diff --git a/plugins/sbt/graphql-java-codegen-sbt-plugin/src/sbt-test/graphql-codegen-sbt-plugin/example-client/project/plugins.sbt b/plugins/sbt/graphql-java-codegen-sbt-plugin/src/sbt-test/graphql-codegen-sbt-plugin/example-client/project/plugins.sbt
index 8b61a3547..4608c8e00 100644
--- a/plugins/sbt/graphql-java-codegen-sbt-plugin/src/sbt-test/graphql-codegen-sbt-plugin/example-client/project/plugins.sbt
+++ b/plugins/sbt/graphql-java-codegen-sbt-plugin/src/sbt-test/graphql-codegen-sbt-plugin/example-client/project/plugins.sbt
@@ -1 +1 @@
-addSbtPlugin("io.github.jxnu-liguobin" % "graphql-codegen-sbt-plugin" % "5.5.1-SNAPSHOT")
+addSbtPlugin("io.github.jxnu-liguobin" % "graphql-codegen-sbt-plugin" % "5.6.0-SNAPSHOT")
diff --git a/plugins/sbt/graphql-java-codegen-sbt-plugin/src/sbt-test/graphql-codegen-sbt-plugin/example-client/version.sbt b/plugins/sbt/graphql-java-codegen-sbt-plugin/src/sbt-test/graphql-codegen-sbt-plugin/example-client/version.sbt
index 4be577733..a761c0701 100644
--- a/plugins/sbt/graphql-java-codegen-sbt-plugin/src/sbt-test/graphql-codegen-sbt-plugin/example-client/version.sbt
+++ b/plugins/sbt/graphql-java-codegen-sbt-plugin/src/sbt-test/graphql-codegen-sbt-plugin/example-client/version.sbt
@@ -1 +1 @@
-version in ThisBuild := "5.5.1-SNAPSHOT"
+version in ThisBuild := "5.6.0-SNAPSHOT"
diff --git a/plugins/sbt/graphql-java-codegen-sbt-plugin/src/sbt-test/graphql-codegen-sbt-plugin/simple/project/plugins.sbt b/plugins/sbt/graphql-java-codegen-sbt-plugin/src/sbt-test/graphql-codegen-sbt-plugin/simple/project/plugins.sbt
index 7f80e8527..b967d6bee 100644
--- a/plugins/sbt/graphql-java-codegen-sbt-plugin/src/sbt-test/graphql-codegen-sbt-plugin/simple/project/plugins.sbt
+++ b/plugins/sbt/graphql-java-codegen-sbt-plugin/src/sbt-test/graphql-codegen-sbt-plugin/simple/project/plugins.sbt
@@ -1,4 +1,4 @@
-sys.props.get("plugin.version").orElse(Some("5.5.1-SNAPSHOT")) match {
+sys.props.get("plugin.version").orElse(Some("5.6.0-SNAPSHOT")) match {
case Some(x) => addSbtPlugin("io.github.jxnu-liguobin" % "graphql-codegen-sbt-plugin" % x)
case _ => sys.error("""|The system property 'plugin.version' is not defined.
|Specify this property using the scriptedLaunchOpts -D.""".stripMargin)
diff --git a/plugins/sbt/graphql-java-codegen-sbt-plugin/src/sbt-test/graphql-codegen-sbt-plugin/simple/version.sbt b/plugins/sbt/graphql-java-codegen-sbt-plugin/src/sbt-test/graphql-codegen-sbt-plugin/simple/version.sbt
index 4be577733..a761c0701 100644
--- a/plugins/sbt/graphql-java-codegen-sbt-plugin/src/sbt-test/graphql-codegen-sbt-plugin/simple/version.sbt
+++ b/plugins/sbt/graphql-java-codegen-sbt-plugin/src/sbt-test/graphql-codegen-sbt-plugin/simple/version.sbt
@@ -1 +1 @@
-version in ThisBuild := "5.5.1-SNAPSHOT"
+version in ThisBuild := "5.6.0-SNAPSHOT"
diff --git a/plugins/sbt/graphql-java-codegen-sbt-plugin/version.sbt b/plugins/sbt/graphql-java-codegen-sbt-plugin/version.sbt
index 4be577733..a761c0701 100644
--- a/plugins/sbt/graphql-java-codegen-sbt-plugin/version.sbt
+++ b/plugins/sbt/graphql-java-codegen-sbt-plugin/version.sbt
@@ -1 +1 @@
-version in ThisBuild := "5.5.1-SNAPSHOT"
+version in ThisBuild := "5.6.0-SNAPSHOT"
From 8f4dee2ff5bee9bb82d4240b3c24d05acc755d1c Mon Sep 17 00:00:00 2001
From: Bogdan Kobylynskyi <92bogdan@gmail.com>
Date: Sun, 26 Feb 2023 12:52:36 -0500
Subject: [PATCH 10/25] Fix line separator tests (#1039)
---
.../GraphQLCodegenAnnotationsTest.java | 96 +++++++++----------
.../graphql/codegen/GraphQLCodegenTest.java | 9 +-
.../scala/GraphQLCodegenAnnotationsTest.java | 60 ++++++------
3 files changed, 79 insertions(+), 86 deletions(-)
diff --git a/src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenAnnotationsTest.java b/src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenAnnotationsTest.java
index 811224722..511da3584 100644
--- a/src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenAnnotationsTest.java
+++ b/src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenAnnotationsTest.java
@@ -53,9 +53,9 @@ void generate_CustomAnnotationMappings() throws Exception {
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
assertFileContainsElements(files, "Event.java",
- "@com.fasterxml.jackson.databind.annotation.JsonDeserialize(" +
- "using = com.example.json.DateTimeScalarDeserializer.class)"
- + System.lineSeparator() + " private org.joda.time.DateTime createdDateTime;");
+ "@com.fasterxml.jackson.databind.annotation.JsonDeserialize(",
+ "using = com.example.json.DateTimeScalarDeserializer.class)",
+ " private org.joda.time.DateTime createdDateTime;");
}
@Test
@@ -69,9 +69,9 @@ void generate_CustomAnnotationMappings_Type() throws Exception {
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
assertFileContainsElements(files, "Event.java",
- "@com.fasterxml.jackson.databind.annotation.JsonDeserialize(" +
- "using = com.example.json.DateTimeScalarDeserializer.class)"
- + System.lineSeparator() + " private org.joda.time.DateTime createdDateTime;");
+ "@com.fasterxml.jackson.databind.annotation.JsonDeserialize(",
+ "using = com.example.json.DateTimeScalarDeserializer.class)",
+ " private org.joda.time.DateTime createdDateTime;");
}
@Test
@@ -85,9 +85,9 @@ void generate_CustomAnnotationMappings_Regexp() throws Exception {
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
assertFileContainsElements(files, "Event.java",
- "@com.fasterxml.jackson.databind.annotation.JsonDeserialize(" +
- "using = com.example.json.DateTimeScalarDeserializer.class)"
- + System.lineSeparator() + " private org.joda.time.DateTime createdDateTime;");
+ "@com.fasterxml.jackson.databind.annotation.JsonDeserialize(",
+ "using = com.example.json.DateTimeScalarDeserializer.class)",
+ " private org.joda.time.DateTime createdDateTime;");
}
@Test
@@ -101,9 +101,9 @@ void generate_CustomAnnotationMappings_FieldType() throws Exception {
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
assertFileContainsElements(files, "Event.java",
- "@com.fasterxml.jackson.databind.annotation.JsonDeserialize(" +
- "using = com.example.json.DateTimeScalarDeserializer.class)"
- + System.lineSeparator() + " private org.joda.time.DateTime createdDateTime;");
+ "@com.fasterxml.jackson.databind.annotation.JsonDeserialize(",
+ "using = com.example.json.DateTimeScalarDeserializer.class)",
+ " private org.joda.time.DateTime createdDateTime;");
}
@Test
@@ -117,9 +117,9 @@ void generate_CustomAnnotationMappings_FieldType_Regexp() throws Exception {
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
assertFileContainsElements(files, "Event.java",
- "@com.fasterxml.jackson.databind.annotation.JsonDeserialize(" +
- "using = com.example.json.DateTimeScalarDeserializer.class)"
- + System.lineSeparator() + " private org.joda.time.DateTime createdDateTime;");
+ "@com.fasterxml.jackson.databind.annotation.JsonDeserialize(",
+ "using = com.example.json.DateTimeScalarDeserializer.class)",
+ " private org.joda.time.DateTime createdDateTime;");
}
@Test
@@ -151,25 +151,25 @@ void generate_CustomAnnotationMappings_Class() throws Exception {
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
assertFileContainsElements(files, "AcceptTopicSuggestionInput.java",
- "@com.fasterxml.jackson.databind.annotation.JsonDeserialize(" +
- "using = AcceptTopicSuggestionInputDeserializer.class)"
- + System.lineSeparator() + "public class AcceptTopicSuggestionInput ");
+ "@com.fasterxml.jackson.databind.annotation.JsonDeserialize(",
+ "using = AcceptTopicSuggestionInputDeserializer.class)",
+ "public class AcceptTopicSuggestionInput ");
assertFileContainsElements(files, "AcceptTopicSuggestionPayload.java",
- "@com.fasterxml.jackson.databind.annotation.JsonDeserialize(" +
- "using = AcceptTopicSuggestionPayloadDeserializer.class)"
- + System.lineSeparator() + "public class AcceptTopicSuggestionPayload ");
+ "@com.fasterxml.jackson.databind.annotation.JsonDeserialize(",
+ "using = AcceptTopicSuggestionPayloadDeserializer.class)",
+ "public class AcceptTopicSuggestionPayload ");
assertFileContainsElements(files, "Actor.java",
- "@com.fasterxml.jackson.databind.annotation.JsonDeserialize(" +
- "using = ActorDeserializer.class)"
- + System.lineSeparator() + "public interface Actor ");
+ "@com.fasterxml.jackson.databind.annotation.JsonDeserialize(",
+ "using = ActorDeserializer.class)",
+ "public interface Actor ");
assertFileContainsElements(files, "Assignee.java",
- "@com.fasterxml.jackson.databind.annotation.JsonDeserialize(" +
- "using = AssigneeDeserializer.class)"
- + System.lineSeparator() + "public interface Assignee ");
+ "@com.fasterxml.jackson.databind.annotation.JsonDeserialize(",
+ "using = AssigneeDeserializer.class)",
+ "public interface Assignee ");
assertFileContainsElements(files, "DeploymentOrderField.java",
- "@com.fasterxml.jackson.databind.annotation.JsonDeserialize(" +
- "using = DeploymentOrderFieldDeserializer.class)"
- + System.lineSeparator() + "public enum DeploymentOrderField ");
+ "@com.fasterxml.jackson.databind.annotation.JsonDeserialize(",
+ "using = DeploymentOrderFieldDeserializer.class)",
+ "public enum DeploymentOrderField ");
}
@Test
@@ -187,13 +187,11 @@ void generate_CustomAnnotationMappings_Multiple() throws Exception {
generate("src/test/resources/schemas/github.graphqls");
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
- assertFileContainsElements(files, "AcceptTopicSuggestionPayload.java", System.lineSeparator() +
- "@com.fasterxml.jackson.annotation.JsonTypeInfo(" +
- "use = com.fasterxml.jackson.annotation.JsonTypeInfo.Id.NAME, property = \"__typename\")"
- + System.lineSeparator() +
- "@com.fasterxml.jackson.databind.annotation.JsonTypeIdResolver(" +
- "io.github.kobylynskyi.order.external.starwars.AcceptTopicSuggestionPayloadTypeResolver.class)"
- + System.lineSeparator() +
+ assertFileContainsElements(files, "AcceptTopicSuggestionPayload.java",
+ "@com.fasterxml.jackson.annotation.JsonTypeInfo(",
+ "use = com.fasterxml.jackson.annotation.JsonTypeInfo.Id.NAME, property = \"__typename\")",
+ "@com.fasterxml.jackson.databind.annotation.JsonTypeIdResolver(",
+ "io.github.kobylynskyi.order.external.starwars.AcceptTopicSuggestionPayloadTypeResolver.class)",
"public class AcceptTopicSuggestionPayload ");
}
@@ -247,15 +245,13 @@ void generate_CustomAnnotationMappings_RequestResponseClasses() throws Exception
File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());
assertFileContainsElements(files, "CodeOfConductQueryRequest.java",
- "@com.fasterxml.jackson.databind.annotation.JsonDeserialize(" +
- "using = CodeOfConductQueryRequestDeserializer.class)"
- + System.lineSeparator() +
- "public class CodeOfConductQueryRequest implements GraphQLOperationRequest {");
+ "@com.fasterxml.jackson.databind.annotation.JsonDeserialize(",
+ "using = CodeOfConductQueryRequestDeserializer.class)",
+ "public class CodeOfConductQueryRequest implements GraphQLOperationRequest {");
assertFileContainsElements(files, "CodeOfConductQueryResponse.java",
- "@com.fasterxml.jackson.databind.annotation.JsonDeserialize(" +
- "using = CodeOfConductQueryResponseDeserializer.class)"
- + System.lineSeparator() +
- "public class CodeOfConductQueryResponse extends GraphQLResult