From 2ea4b0361c0913bdf371023b0aca4c714b5cfaf5 Mon Sep 17 00:00:00 2001 From: Paul Date: Sun, 20 Aug 2023 23:06:33 +0800 Subject: [PATCH] fix mima --- core/src/main/scala/caliban/Rendering.scala | 3 +++ .../main/scala/caliban/rendering/DocumentRenderer.scala | 7 +++++-- core/src/main/scala/caliban/rendering/Renderer.scala | 3 +++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/core/src/main/scala/caliban/Rendering.scala b/core/src/main/scala/caliban/Rendering.scala index c5aed03b6f..0d30382558 100644 --- a/core/src/main/scala/caliban/Rendering.scala +++ b/core/src/main/scala/caliban/Rendering.scala @@ -19,6 +19,9 @@ object Rendering { def renderSchemaDirectives(directives: List[Directive]): String = DocumentRenderer.directivesRenderer.render(directives) + def renderDirectives(directives: List[__Directive]): String = + DocumentRenderer.directiveDefinitionsRenderer.render(directives.map(_.toDirectiveDefinition)) + @deprecated("Prefer DocumentRenderer.descriptionRenderer instead", "2.3.1") private[caliban] def renderDescription(description: Option[String], newline: Boolean = true): String = if (newline) DocumentRenderer.descriptionRenderer.render(description) diff --git a/core/src/main/scala/caliban/rendering/DocumentRenderer.scala b/core/src/main/scala/caliban/rendering/DocumentRenderer.scala index 436ce82980..f5448d144a 100644 --- a/core/src/main/scala/caliban/rendering/DocumentRenderer.scala +++ b/core/src/main/scala/caliban/rendering/DocumentRenderer.scala @@ -47,13 +47,16 @@ object DocumentRenderer extends Renderer[Document] { } private[caliban] lazy val documentRenderer: Renderer[Document] = Renderer.combine( - directiveDefinitionRenderer.list(Renderer.char('\n')).contramap(_.directiveDefinitions), + directiveDefinitionsRenderer.contramap(_.directiveDefinitions), schemaRenderer.optional.contramap(_.schemaDefinition), operationDefinitionRenderer.list(Renderer.newlineOrSpace).contramap(_.operationDefinitions), typeDefinitionsRenderer.contramap(_.typeDefinitions), fragmentRenderer.list.contramap(_.fragmentDefinitions) ) + private[caliban] lazy val directiveDefinitionsRenderer: Renderer[List[DirectiveDefinition]] = + directiveDefinitionRenderer.list(Renderer.newline) + private[caliban] lazy val __typeNameRenderer: Renderer[__Type] = new Renderer[__Type] { override def unsafeRender(value: __Type, indent: Option[Int], write: StringBuilder): Unit = { def loop(typ: Option[__Type]): Unit = typ match { @@ -77,7 +80,7 @@ object DocumentRenderer extends Renderer[Document] { } } - private lazy val directiveDefinitionRenderer: Renderer[DirectiveDefinition] = + private[caliban] lazy val directiveDefinitionRenderer: Renderer[DirectiveDefinition] = new Renderer[DirectiveDefinition] { private val inputRenderer = inputValueDefinitionRenderer.list(Renderer.char(',') ++ Renderer.space) private val locationsRenderer: Renderer[Set[DirectiveLocation]] = diff --git a/core/src/main/scala/caliban/rendering/Renderer.scala b/core/src/main/scala/caliban/rendering/Renderer.scala index 13ba72fead..990b953cb0 100644 --- a/core/src/main/scala/caliban/rendering/Renderer.scala +++ b/core/src/main/scala/caliban/rendering/Renderer.scala @@ -158,6 +158,9 @@ object Renderer { if (indent.isDefined) write.append('\n') else write.append(' ') } + lazy val newline: Renderer[Any] = + Renderer.char('\n') + private final case class Combined[-A](renderers: List[Renderer[A]]) extends Renderer[A] { override def unsafeRender(value: A, indent: Option[Int], write: StringBuilder): Unit = renderers.foreach(_.unsafeRender(value, indent, write))