Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update/caliban 2.4.1 #373

Merged
merged 1 commit into from
Oct 24, 2023
Merged
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
6 changes: 3 additions & 3 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -170,16 +170,16 @@ lazy val `quill-caliban` =
.settings(
Test / fork := true,
libraryDependencies ++= Seq(
"com.github.ghostdogpr" %% "caliban" % "2.0.2",
"com.github.ghostdogpr" %% "caliban-zio-http" % "2.0.2",
"com.github.ghostdogpr" %% "caliban" % "2.4.1",
"com.github.ghostdogpr" %% "caliban-zio-http" % "2.4.1",
// Adding this to main dependencies would force users to use logback-classic for SLF4j unless the specifically remove it
// seems to be safer to just exclude & add a commented about need for a SLF4j implementation in Docs.
"ch.qos.logback" % "logback-classic" % "1.4.11" % Test,
"io.d11" %% "zhttp" % "2.0.0-RC11" % Test,
// Don't want to make this dependant on zio-test for the testing code so importing this here separately
"org.scalatest" %% "scalatest" % scalatestVersion % Test,
"org.scalatest" %% "scalatest-mustmatchers" % scalatestVersion % Test,
"org.postgresql" % "postgresql" % "42.6.0" % Test,
"com.softwaremill.sttp.tapir" %% "tapir-json-zio" % "1.7.3" % Test
)
)
.dependsOn(`quill-jdbc-zio` % "compile->compile")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package io.getquill

import caliban.CalibanError.ExecutionError
import caliban.GraphQL.graphQL
import caliban.graphQL
import caliban.introspection.adt.{ __InputValue, __Type, __TypeKind }
import caliban.schema.{ ArgBuilder, Schema, Step }
import caliban.{ InputValue, RootResolver }
Expand Down Expand Up @@ -47,17 +47,18 @@ object CalibanIntegration {
case __TypeKind.NON_NULL => fieldType.ofType.getOrElse(fieldType)
case _ => fieldType
}
f.copy(`type` =
() => optionalFieldType.copy(inputFields = optionalFieldType.inputFields.map(_.map(makeOptionalRecurse)))
import io.getquill.autoQuote
f.copy(`type` = () =>
optionalFieldType.copy(inputFields = args => optionalFieldType.inputFields(args).map(_.map(makeOptionalRecurse)))
)
}

protected[this] def toType(isInput: Boolean, isSubscription: Boolean): __Type =
def toType(isInput: Boolean, isSubscription: Boolean): __Type =
__Type(
__TypeKind.INPUT_OBJECT,
inputFields = ev
inputFields = args => ev
.toType_(isInput, isSubscription)
.inputFields
.inputFields(args)
.map(_.map(f => makeOptionalRecurse(f)))
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@ import zio.{ZIO, Task}
import io.getquill.context.ZioJdbc._
import caliban.execution.Field
import caliban.schema.ArgBuilder
import caliban.GraphQL.graphQL
import caliban.graphQL
import caliban.schema.Annotations.GQLDescription
import caliban.RootResolver
import io.getquill.CalibanIntegration._
import caliban.schema._
import caliban.schema.Schema.auto._
import caliban.schema.ArgBuilder.auto._

class CalibanIntegrationNestedSpec extends CalibanSpec {
import Ctx._
Expand All @@ -22,13 +25,16 @@ class CalibanIntegrationNestedSpec extends CalibanSpec {
.filterByKeys(filters)
.filterColumns(columns)
.take(10)
}.provideLayer(zioDS).tap(list => {
println(s"Results: $list for columns: $columns and filters: ${io.getquill.util.Messages.qprint(filters)}")
ZIO.unit
})
.tapError(e => {
println(s"ERROR $e")
ZIO.unit
}.provideLayer(zioDS).tapBoth({
e => {
println(s"ERROR $e")
ZIO.unit
}
}, {
list => {
println(s"Results: $list for columns: $columns and filters: ${io.getquill.util.Messages.qprint(filters)}")
ZIO.unit
}
})
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ import zio.{ZIO, Task}
import io.getquill.context.ZioJdbc._
import caliban.execution.Field
import caliban.schema.ArgBuilder
import caliban.GraphQL.graphQL
import caliban.graphQL
import caliban.schema.Annotations.GQLDescription
import caliban.RootResolver
import io.getquill.CalibanIntegration._
import caliban.schema.Schema.auto._
import caliban.schema.ArgBuilder.auto._

class CalibanIntegrationSpec extends CalibanSpec {
import Ctx._
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package io.getquill

import caliban.GraphQL.graphQL
import caliban.graphQL
import caliban.schema.Annotations.GQLDescription
import caliban.{RootResolver, ZHttpAdapter}
import zhttp.http._
import zhttp.service.Server
import zio.http._
import zio.http.Server
import zio.{ExitCode, ZIO}
import io.getquill._
import io.getquill.context.qzio.ImplicitSyntax._
Expand All @@ -22,7 +22,13 @@ import io.getquill.CalibanIntegration._
import io.getquill.util.ContextLogger
import io.getquill
import io.getquill.FlatSchema._

import caliban.interop.tapir.HttpInterpreter
import caliban.schema.Schema.auto._
import caliban.schema.ArgBuilder.auto._
import sttp.tapir.json.zio.*
import zio.json.JsonEncoder
import zio.json.JsonDecoder
import caliban._

object Dao {
case class PersonAddressPlanQuery(plan: String, pa: List[PersonAddress])
Expand Down Expand Up @@ -91,16 +97,18 @@ object CalibanExample extends zio.ZIOAppDefault {
)
)
).interpreter

given JsonEncoder[GraphQLRequest] = GraphQLRequest.zioJsonEncoder

given JsonDecoder[GraphQLRequest] = GraphQLRequest.zioJsonDecoder

val myApp = for {
_ <- Dao.resetDatabase()
interpreter <- endpoints
_ <- Server.start(
port = 8088,
http = Http.collectHttp[Request] { case _ -> !! / "api" / "graphql" =>
ZHttpAdapter.makeHttpService(interpreter)
_ <- Server.serve(Http.collectHttp[Request] { case _ -> Root / "api" / "graphql" =>
ZHttpAdapter.makeHttpService(HttpInterpreter(interpreter))
}
)
).provide(Server.defaultWithPort(8088))
.forever
} yield ()

Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,34 @@
package io.getquill

import caliban.GraphQL.graphQL
import caliban.graphQL
import caliban.schema.Annotations.GQLDescription
import caliban.{RootResolver, ZHttpAdapter}
import zhttp.http._
import zhttp.service.Server
import zio.http.*
import zio.http.Server
import zio.{ExitCode, ZIO}
import io.getquill._
import io.getquill.context.qzio.ImplicitSyntax._
import io.getquill.context.ZioJdbc._
import io.getquill.*
import io.getquill.context.qzio.ImplicitSyntax.*
import io.getquill.context.ZioJdbc.*
import io.getquill.util.LoadConfig
import zio.Console.printLine
import zio.{ ZIOApp, ExitCode, URIO, Task }
import zio.{ExitCode, Task, URIO, ZIOApp}

import java.io.Closeable
import javax.sql.DataSource

import scala.language.postfixOps
import caliban.execution.Field
import caliban.schema.ArgBuilder
import io.getquill.CalibanIntegration._
import io.getquill.CalibanIntegration.*
import io.getquill.util.ContextLogger
import io.getquill.NestedSchema._
import io.getquill.NestedSchema.*
import caliban.schema.Schema.auto.*
import caliban.schema.ArgBuilder.auto.*
import zio.http.Server
import caliban.interop.tapir.HttpInterpreter
import sttp.tapir.json.zio.*
import zio.json.JsonEncoder
import zio.json.JsonDecoder
import caliban._


object DaoNested {
Expand Down Expand Up @@ -96,12 +104,11 @@ object CalibanExampleNested extends zio.ZIOAppDefault {
val myApp = for {
_ <- DaoNested.resetDatabase()
interpreter <- endpoints
_ <- Server.start(
port = 8088,
http = Http.collectHttp[Request] { case _ -> !! / "api" / "graphql" =>
ZHttpAdapter.makeHttpService(interpreter)
_ <- Server.serve(
Http.collectHttp[Request] { case _ -> Root / "api" / "graphql" =>
ZHttpAdapter.makeHttpService(HttpInterpreter(interpreter))
}
)
).provide(Server.defaultWithPort(8088))
.forever
} yield ()

Expand Down