File tree Expand file tree Collapse file tree 3 files changed +14
-2
lines changed
main/kotlin/com/expedia/graphql
test/kotlin/com/expedia/graphql/schema/generator Expand file tree Collapse file tree 3 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -3,4 +3,4 @@ package com.expedia.graphql.schema.exceptions
33/* *
44 * Exception thrown on schema creation if no queries and no mutations are specified.
55 */
6- class InvalidSchemaException : GraphQLKotlinException (" Schema requires at least one query or mutation " )
6+ class InvalidSchemaException : GraphQLKotlinException (" Schema requires at least one query" )
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ fun toSchema(
1717 mutations : List <TopLevelObjectDef > = emptyList(),
1818 config : SchemaGeneratorConfig
1919): GraphQLSchema {
20- if (queries.isEmpty() && mutations.isEmpty() ) {
20+ if (queries.isEmpty()) {
2121 throw InvalidSchemaException ()
2222 }
2323 return SchemaGenerator (queries, mutations, config).generate()
Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ import java.net.CookieManager
1818import java.util.UUID
1919import kotlin.test.Test
2020import kotlin.test.assertEquals
21+ import kotlin.test.assertFailsWith
2122import kotlin.test.assertNotNull
2223import kotlin.test.assertTrue
2324
@@ -38,6 +39,17 @@ class SchemaGeneratorTest {
3839 assertEquals(1 , geo?.get(" query" )?.get(" id" ))
3940 }
4041
42+ @Test
43+ fun `SchemaGenerator throws exception on a mutation only schema` () {
44+ assertFailsWith(InvalidSchemaException ::class ) {
45+ toSchema(
46+ emptyList(),
47+ listOf (TopLevelObjectDef (MutationObject ())),
48+ config = testSchemaConfig
49+ )
50+ }
51+ }
52+
4153 @Test
4254 fun `Schema generator exposes arrays of primitive types as function arguments` () {
4355 val schema = toSchema(listOf (TopLevelObjectDef (QueryWithArray ())), config = testSchemaConfig)
You can’t perform that action at this time.
0 commit comments