Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/src/main/kotlin/me/lazmaid/kraph/Kraph.kt
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class Kraph(f: Kraph.() -> Unit) {
open inner class FieldBuilder {
internal val fields = arrayListOf<Field>()

fun fieldObject(name: String, alias: String? = null, args: Map<String, Any>? = null, builder: FieldBlock) {
fun fieldObject(name: String, alias: String? = null, args: Map<String, Any>? = null, builder: FieldBlock? = null) {
addField(name, alias, args, builder)
}

Expand Down
15 changes: 15 additions & 0 deletions core/src/test/kotlin/me/lazmaid/kraph/test/BuilderSpek.kt
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,21 @@ class BuilderSpek : Spek({
}, throws(noFieldInSelectionSetMessageMatcher("test")))
}
}
given("sample query with object and no supplied field builder") {
val query = Kraph {
query {
fieldObject("test")
}
}
it("should not throw a NoFieldsInSelectionSetException and build the request correctly") {
assertThat(
query.toRequestString(),
equalTo(
"{\"query\": \"query { test }\", \"variables\": null, \"operationName\": null}"
)
)
}
}
given("sample mutation") {
val query = Kraph {
mutation {
Expand Down