Skip to content

Commit b74ae0d

Browse files
committed
chore(codegen): KotlinTypeMapper: add comments
1 parent 53a8ced commit b74ae0d

File tree

1 file changed

+9
-4
lines changed
  • graphql-kotlin-toolkit-codegen/src/main/kotlin/com/auritylab/graphql/kotlin/toolkit/codegen/mapper

1 file changed

+9
-4
lines changed

graphql-kotlin-toolkit-codegen/src/main/kotlin/com/auritylab/graphql/kotlin/toolkit/codegen/mapper/KotlinTypeMapper.kt

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,16 @@ internal class KotlinTypeMapper(
9494
}
9595

9696
/**
97-
* Will take the given [scalarTypeDefinition] and check if it's a default scalar or a custom one.
97+
* Will return the according [ClassName] of the given [scalar]. If the given scalar is no built-in scalar, it will
98+
* check if there is a representation class and return the [ClassName] of it. If it's no built-in scalar, and no
99+
* representation class is given, it will simply return Any.
100+
*
101+
* @param scalar The scalar for which to get the [ClassName] for.
102+
* @return The [ClassName] for the given [scalar].
98103
*/
99-
private fun getScalarKotlinType(scalarTypeDefinition: GraphQLScalarType): ClassName {
104+
private fun getScalarKotlinType(scalar: GraphQLScalarType): ClassName {
100105
// Check for the default scalars of GraphQL itself and the `graphql-java` library.
101-
val defaultClass = when (scalarTypeDefinition.name) {
106+
val defaultClass = when (scalar.name) {
102107
"String" -> STRING
103108
"Boolean" -> BOOLEAN
104109
"Int" -> INT
@@ -116,7 +121,7 @@ internal class KotlinTypeMapper(
116121
if (defaultClass != null) return defaultClass
117122

118123
// Fetch the kotlin representation class or return "Any".
119-
return DirectiveFacade.representation.getArguments(scalarTypeDefinition)
124+
return DirectiveFacade.representation.getArguments(scalar)
120125
?.className?.let { ClassName.bestGuess(it) }
121126
?: ANY
122127
}

0 commit comments

Comments
 (0)