@@ -27,8 +27,6 @@ import graphql.schema.idl.TypeUtil
2727import kotlinx.serialization.json.*
2828import java.math.BigDecimal
2929import java.math.BigInteger
30- import kotlin.math.abs
31- import kotlin.random.Random
3230
3331@Suppress(" FoldInitializerAndIfToElvis" )
3432class DocGenerator (private val config : CodeGenConfig , private val document : Document ) {
@@ -116,13 +114,15 @@ class DocGenerator(private val config: CodeGenConfig, private val document: Docu
116114 private fun getExampleEntitiesQuery (definition : ObjectTypeDefinition ): String? {
117115 val gql: String = """
118116 query(${' $' } representations: [_Any!]!) {
119- ... on ${definition.name} {
120- ${definition.fieldDefinitions.map {
117+ entities(representations: ${' $' } representations) {
118+ ... on ${definition.name} {
119+ ${definition.fieldDefinitions.map {
121120 val selectionSet : List <String > = getSelectionSet(it.type.findTypeDefinition(document))
122121 """
123122 ${it.name}${if (it.inputValueDefinitions.size > 0 ) " (${it.inputValueDefinitions.map{ " ${it.name} : ${getMockGQLValueAsAST(it.type)} " }.joinToString(" , " )} )" else " " } ${if (selectionSet.size > 0 ) " {${selectionSet.joinToString(" \n " )} }" else " " }
124123 """
125124 }.joinToString(" \n " )}
125+ }
126126 }
127127 }
128128 """ .trimIndent()
@@ -194,11 +194,11 @@ class DocGenerator(private val config: CodeGenConfig, private val document: Docu
194194
195195 if (type is TypeName ) {
196196 return when (type.name) {
197- " ID" -> StringValue (" random ${ Random .nextInt()} " )
197+ " ID" -> StringValue (" random12345 " )
198198 " String" -> StringValue (" randomString" )
199- " Boolean" -> BooleanValue (Random .nextBoolean() )
200- " Int" -> IntValue (BigInteger .valueOf(abs( Random .nextLong()) ))
201- " Float" -> FloatValue (BigDecimal .valueOf(abs( Random .nextDouble()) ))
199+ " Boolean" -> BooleanValue (true )
200+ " Int" -> IntValue (BigInteger .valueOf(123456789 ))
201+ " Float" -> FloatValue (BigDecimal .valueOf(12345.6789 ))
202202 else -> {
203203 getSchemaTypeMockValue(type)
204204 }
0 commit comments