@@ -27,8 +27,6 @@ import graphql.schema.idl.TypeUtil
27
27
import kotlinx.serialization.json.*
28
28
import java.math.BigDecimal
29
29
import java.math.BigInteger
30
- import kotlin.math.abs
31
- import kotlin.random.Random
32
30
33
31
@Suppress(" FoldInitializerAndIfToElvis" )
34
32
class DocGenerator (private val config : CodeGenConfig , private val document : Document ) {
@@ -116,13 +114,15 @@ class DocGenerator(private val config: CodeGenConfig, private val document: Docu
116
114
private fun getExampleEntitiesQuery (definition : ObjectTypeDefinition ): String? {
117
115
val gql: String = """
118
116
query(${' $' } representations: [_Any!]!) {
119
- ... on ${definition.name} {
120
- ${definition.fieldDefinitions.map {
117
+ entities(representations: ${' $' } representations) {
118
+ ... on ${definition.name} {
119
+ ${definition.fieldDefinitions.map {
121
120
val selectionSet : List <String > = getSelectionSet(it.type.findTypeDefinition(document))
122
121
"""
123
122
${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 " " }
124
123
"""
125
124
}.joinToString(" \n " )}
125
+ }
126
126
}
127
127
}
128
128
""" .trimIndent()
@@ -194,11 +194,11 @@ class DocGenerator(private val config: CodeGenConfig, private val document: Docu
194
194
195
195
if (type is TypeName ) {
196
196
return when (type.name) {
197
- " ID" -> StringValue (" random ${ Random .nextInt()} " )
197
+ " ID" -> StringValue (" random12345 " )
198
198
" 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 ))
202
202
else -> {
203
203
getSchemaTypeMockValue(type)
204
204
}
0 commit comments