Skip to content

Commit a1d9d7b

Browse files
authored
Merge pull request #7 from mstachniuk/ms
#3 Add support for default values in arguments of operations
2 parents badd652 + ccc5d01 commit a1d9d7b

File tree

7 files changed

+965
-33
lines changed

7 files changed

+965
-33
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@
66
*/build/
77
*/out
88
!gradle/wrapper/gradle-wrapper.jar
9+
.gradletasknamecache

core/build.gradle

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
buildscript {
22
ext.kotlin_version = '1.2.31'
3+
ext.junitVersion = "5.2.0"
34
ext.dokka_version = '0.9.17'
45

56
repositories {
@@ -24,8 +25,9 @@ configurations {
2425
dependencies {
2526
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
2627
compile 'com.beust:klaxon:3.0.1'
27-
testCompile "org.junit.jupiter:junit-jupiter-api:5.2.0"
28-
testCompile "org.junit.jupiter:junit-jupiter-params:5.2.0"
28+
testCompile "org.junit.jupiter:junit-jupiter-api:$junitVersion"
29+
testCompile "org.junit.jupiter:junit-jupiter-params:$junitVersion"
30+
testRuntime "org.junit.jupiter:junit-jupiter-engine:$junitVersion"
2931
testCompile 'org.json:json:20180813'
3032
testCompile 'com.graphql-java:graphql-java:2018-08-23T21-16-30-141b8e4'
3133
testCompile 'org.skyscreamer:jsonassert:1.5.0'
@@ -39,6 +41,13 @@ compileTestKotlin {
3941
kotlinOptions.jvmTarget = "1.8"
4042
}
4143

44+
tasks.withType(Test) {
45+
useJUnitPlatform()
46+
testLogging {
47+
events("passed", "skipped", "failed")
48+
}
49+
}
50+
4251
task ktlint(type: JavaExec, group: "verification") {
4352
description = "Check Kotlin code style."
4453
classpath = configurations.ktlint

core/src/main/kotlin/io/github/mstachniuk/graphqlschemafromintrospectiongenerator/internal/GeneratorImpl.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class GeneratorImpl {
1010
fun generate(input: String): String {
1111
val response = Klaxon().parse<IntrospectionResponse>(input) ?: return ""
1212

13-
var output = printTypes(response)
13+
val output = printTypes(response)
1414

1515
return output.trimIndent().trimIndent()
1616
}
@@ -84,7 +84,7 @@ class GeneratorImpl {
8484
var output = ""
8585
if (it.description.isNotBlank()) {
8686
if (addMargin) {
87-
output += "$margin"
87+
output += margin
8888
}
8989
output += "# ${it.description.trim().replace("\n", "\n$margin# ")}\n"
9090
}
@@ -137,7 +137,7 @@ class GeneratorImpl {
137137
}
138138
} else {
139139
val arguments = args
140-
.map { "${it.name}: ${printType(it.type)}" }
140+
.map { "${it.name}: ${printType(it.type)}${printDefaultValue(it)}" }
141141
.joinToString(", ")
142142
if (arguments.isNotBlank()) {
143143
return "($arguments)"

0 commit comments

Comments
 (0)