@@ -42,6 +42,7 @@ import static graphql.schema.GraphQLNonNull.nonNull
4242import static graphql.schema.GraphQLObjectType.newObject
4343import static graphql.schema.GraphQLScalarType.newScalar
4444import static graphql.schema.idl.RuntimeWiring.newRuntimeWiring
45+ import static graphql.schema.idl.SchemaPrinter.ExcludeGraphQLSpecifiedDirectivesPredicate
4546import static graphql.schema.idl.SchemaPrinter.Options.defaultOptions
4647
4748class SchemaPrinterTest extends Specification {
@@ -75,7 +76,7 @@ class SchemaPrinterTest extends Specification {
7576 throw new UnsupportedOperationException (" Not implemented" )
7677 }
7778 })
78- .build()
79+ .build()
7980
8081 def resolver = new TypeResolver () {
8182
@@ -514,7 +515,7 @@ type Query {
514515
515516 def " prints scalar description as comment" () {
516517 given :
517- GraphQLScalarType myScalar = newScalar(). name(" Scalar" ). description( " about scalar" ). coercing(new Coercing () {
518+ GraphQLScalarType myScalar = newScalar(). name(" Scalar" ). description(" about scalar" ). coercing(new Coercing () {
518519 @Override
519520 Object serialize (Object input ) {
520521 return null
@@ -530,7 +531,7 @@ type Query {
530531 return null
531532 }
532533 })
533- .build()
534+ .build()
534535 GraphQLFieldDefinition fieldDefinition = newFieldDefinition()
535536 .name(" field" ). type(myScalar). build()
536537 def queryType = newObject(). name(" Query" ). field(fieldDefinition). build()
@@ -1648,7 +1649,7 @@ scalar CustomScalar
16481649 return null
16491650 }
16501651 })
1651- .build()
1652+ .build()
16521653
16531654 GraphQLFieldDefinition fieldDefinition = newFieldDefinition()
16541655 .name(" scalarType" ). type(myScalar). build()
@@ -1690,7 +1691,7 @@ scalar RandomScalar
16901691 return null
16911692 }
16921693 })
1693- .build()
1694+ .build()
16941695
16951696 GraphQLFieldDefinition fieldDefinition = newFieldDefinition()
16961697 .name(" someType" ). type(GraphQLInt ). build()
@@ -1907,4 +1908,22 @@ type MyQuery {
19071908 result == """ directive @foo on FIELD_DEFINITION"""
19081909 }
19091910
1911+ def " description printing escapes triple quotes" () {
1912+ def descriptionWithTripleQuote = ' Hello """ \n World """ """' ;
1913+ def field = newFieldDefinition(). name(" hello" ). type(GraphQLString ). build()
1914+ def queryType = newObject(). name(" Query" ). field(field). description(descriptionWithTripleQuote). build()
1915+ def schema = GraphQLSchema . newSchema(). query(queryType). build()
1916+ when :
1917+ def result = new SchemaPrinter (defaultOptions(). includeDirectives(ExcludeGraphQLSpecifiedDirectivesPredicate )). print (schema)
1918+
1919+ then :
1920+ result == ''' """
1921+ Hello \\ """
1922+ World \\ """ \\ """
1923+ """
1924+ type Query {
1925+ hello: String
1926+ }
1927+ '''
1928+ }
19101929}
0 commit comments