Skip to content

Commit

Permalink
Merge pull request #541 from Netflix/bug-fixes
Browse files Browse the repository at this point in the history
Do not apply maxProjectionDepth for client V2 API, not required to limit the generation.
  • Loading branch information
srinivasankavitha authored Apr 4, 2023
2 parents 0f283a0 + dd15435 commit b60525b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ class ClientApiGeneratorv2(private val config: CodeGenConfig, private val docume
.filter { it.name == type.name }
.flatMap { it.fieldDefinitions }

val codeGenResult = if (queryDepth < config.maxProjectionDepth || config.maxProjectionDepth == -1) {
val codeGenResult =
fieldDefinitions
.filterSkipped()
.mapNotNull {
Expand Down Expand Up @@ -536,7 +536,6 @@ class ClientApiGeneratorv2(private val config: CodeGenConfig, private val docume
createSubProjection(typeDef, javaType.build(), root, "${typeDef.name.capitalized()}", updatedProcessedEdges, queryDepth + 1)
}
.fold(CodeGenResult()) { total, current -> total.merge(current) }
} else CodeGenResult()

fieldDefinitions
.filterSkipped()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ class ClientApiGenQueryTest {
type Query {
movies(filter: MovieQuery): [String]
}
input MovieQuery {
booleanQuery: BooleanQuery!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -491,17 +491,17 @@ class ClientApiGenProjectionTestv2 {
CodeGenConfig(
schemas = setOf(schema),
packageName = basePackageName,
generateClientApiv2 = true,
maxProjectionDepth = 2
generateClientApiv2 = true
)
).generate()

assertThat(codeGenResult.clientProjections.size).isEqualTo(5)
assertThat(codeGenResult.clientProjections.size).isEqualTo(6)
assertThat(codeGenResult.clientProjections[0].typeSpec.name).isEqualTo("MoviesProjectionRoot")
assertThat(codeGenResult.clientProjections[1].typeSpec.name).isEqualTo("RatingProjection")
assertThat(codeGenResult.clientProjections[2].typeSpec.name).isEqualTo("ReviewProjection")
assertThat(codeGenResult.clientProjections[3].typeSpec.name).isEqualTo("ActorProjection")
assertThat(codeGenResult.clientProjections[4].typeSpec.name).isEqualTo("AgentProjection")
assertThat(codeGenResult.clientProjections[5].typeSpec.name).isEqualTo("AddressProjection")

assertCompilesJava(codeGenResult.clientProjections + codeGenResult.javaQueryTypes)
}
Expand Down Expand Up @@ -711,8 +711,7 @@ class ClientApiGenProjectionTestv2 {
CodeGenConfig(
schemas = setOf(schema),
packageName = basePackageName,
generateClientApiv2 = true,
maxProjectionDepth = 2
generateClientApiv2 = true
)
).generate()

Expand Down

0 comments on commit b60525b

Please sign in to comment.