File tree Expand file tree Collapse file tree 2 files changed +27
-2
lines changed
main/kotlin/graphql/kickstart/tools
test/kotlin/graphql/kickstart/tools Expand file tree Collapse file tree 2 files changed +27
-2
lines changed Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ internal class RootTypeInfo private constructor(
1717 const val DEFAULT_QUERY_NAME = " Query"
1818 const val DEFAULT_MUTATION_NAME = " Mutation"
1919 const val DEFAULT_SUBSCRIPTION_NAME = " Subscription"
20- const val DEFAULT_DESCRIPTION = " A GraphQL schema provides a root type for each kind of operation. "
20+ val DEFAULT_DESCRIPTION : String? = null // According to the GraphQL Specification description should be a string or `null`
2121
2222 fun fromSchemaDefinitions (definitions : List <SchemaDefinition >): RootTypeInfo {
2323 val queryType = definitions.lastOrNull()?.operationTypeDefinitions?.find { it.name == " query" }?.typeName
Original file line number Diff line number Diff line change @@ -575,7 +575,7 @@ class SchemaParserTest {
575575 }
576576
577577 @Test
578- fun `parser should include schema descriptions` () {
578+ fun `parser should include schema descriptions when declared ` () {
579579 val schema = SchemaParser .newParser()
580580 .schemaString(
581581 """
@@ -600,6 +600,31 @@ class SchemaParserTest {
600600 assertEquals(schema.description, " This is a schema level description" )
601601 }
602602
603+ @Test
604+ fun `parser should return null schema description when not declared` () {
605+ val schema = SchemaParser .newParser()
606+ .schemaString(
607+ """
608+ schema {
609+ query: SubstituteQuery
610+ }
611+
612+ type SubstituteQuery {
613+ description: String
614+ comment: String
615+ omitted: String
616+ both: String
617+ empty: String
618+ }
619+ """ )
620+ .resolvers(object : GraphQLQueryResolver {})
621+ .options(SchemaParserOptions .newOptions().allowUnimplementedResolvers(true ).build())
622+ .build()
623+ .makeExecutableSchema()
624+
625+ assertNull(schema.description)
626+ }
627+
603628 enum class EnumType {
604629 TEST
605630 }
You can’t perform that action at this time.
0 commit comments