Skip to content

Commit

Permalink
Interface always has default projection __typename
Browse files Browse the repository at this point in the history
  • Loading branch information
ermadmi78 committed Jun 28, 2021
1 parent 498f8a1 commit 08cb906
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ private fun FileSpecBuilder.buildProjection(node: KobbyNode, layout: KotlinLayou
}
field.lambda?.also {
buildParameter(it) {
if (!field.isOverride && field.type.hasDefaults) {
if (!field.isOverride && field.type.node.hasDefaults) {
defaultValue("{}")
}
}
Expand Down Expand Up @@ -215,7 +215,9 @@ private fun FileSpecBuilder.buildQualification(node: KobbyNode, layout: KotlinLa
addKdoc(it)
}
buildParameter(entity.projection.projectionArgument, subObject.projectionLambda) {
defaultValue("{}")
if (subObject.hasDefaults) {
defaultValue("{}")
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,10 @@ data class KotlinLayout(
else -> false
}

internal val KobbyType.hasDefaults: Boolean
get() = when (node.kind) {
OBJECT, INTERFACE -> node.fields.values.any { it.isRequired || it.isDefault }
else -> true
internal val KobbyNode.hasDefaults: Boolean
get() = when (kind) {
OBJECT -> fields.values.any { it.isRequired || it.isDefault }
else -> true // unions and interfaces always has default projection __typename
}

internal val KobbyField.entityType: TypeName
Expand Down

0 comments on commit 08cb906

Please sign in to comment.