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

Deprecate makeRestService #125

Merged
merged 2 commits into from
Dec 16, 2019
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
2 changes: 1 addition & 1 deletion examples/src/main/scala/caliban/ExampleApp.scala
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ object ExampleApp extends CatsApp with GenericSchema[Console with Clock] {
.bindHttp(8088, "localhost")
.withHttpApp(
Router[ExampleTask](
"/api/graphql" -> CORS(Http4sAdapter.makeRestService(interpreter)),
"/api/graphql" -> CORS(Http4sAdapter.makeHttpService(interpreter)),
"/ws/graphql" -> CORS(Http4sAdapter.makeWebSocketService(interpreter)),
"/graphiql" -> Kleisli.liftF(StaticFile.fromResource("/graphiql.html", blocker, None))
).orNotFound
Expand Down
14 changes: 12 additions & 2 deletions http4s/src/main/scala/caliban/Http4sAdapter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ object Http4sAdapter {
execute(interpreter, query)
.foldCause(cause => GraphQLResponse(NullValue, cause.defects).asJson, _.asJson)

def makeRestService[R, Q, M, S, E](interpreter: GraphQL[R, Q, M, S, E]): HttpRoutes[RIO[R, *]] = {
@deprecated("Use makeHttpService instead", "0.4.0")
def makeRestService[R, Q, M, S, E](interpreter: GraphQL[R, Q, M, S, E]): HttpRoutes[RIO[R, *]] =
makeHttpService(interpreter)

def makeHttpService[R, Q, M, S, E](interpreter: GraphQL[R, Q, M, S, E]): HttpRoutes[RIO[R, *]] = {
object dsl extends Http4sDsl[RIO[R, *]]
import dsl._

Expand Down Expand Up @@ -173,10 +177,16 @@ object Http4sAdapter {
)(implicit F: Effect[F], runtime: Runtime[Any]): HttpRoutes[F] =
wrapRoute(makeWebSocketService[Any, Q, M, S, E](interpreter))

@deprecated("Use makeHttpServiceF instead", "0.4.0")
def makeRestServiceF[F[_], Q, M, S, E](
interpreter: GraphQL[Any, Q, M, S, E]
)(implicit F: Effect[F], runtime: Runtime[Any]): HttpRoutes[F] =
wrapRoute(makeRestService[Any, Q, M, S, E](interpreter))
makeHttpServiceF(interpreter)

def makeHttpServiceF[F[_], Q, M, S, E](
interpreter: GraphQL[Any, Q, M, S, E]
)(implicit F: Effect[F], runtime: Runtime[Any]): HttpRoutes[F] =
wrapRoute(makeHttpService[Any, Q, M, S, E](interpreter))

def executeRequestF[F[_], Q, M, S, E](
interpreter: GraphQL[Any, Q, M, S, E]
Expand Down
48 changes: 25 additions & 23 deletions vuepress/docs/docs/schema.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,31 @@
A GraphQL schema will be derived automatically at compile-time (no reflection) from the types present in your resolver.
The table below shows how common Scala types are converted to GraphQL types.

| Scala Type | GraphQL Type |
| ---------------- | ------------------------------------------------ |
| Boolean | Boolean |
| Int | Int |
| Float | Float |
| Double | Float |
| String | String |
| java.util.UUID | String |
| Unit | Unit (custom scalar) |
| Long | Long (custom scalar) |
| BigInt | BigInt (custom scalar) |
| BigDecimal | BigDecimal (custom scalar) |
| Case Class | Object |
| Sealed Trait | Enum or Union |
| Option[A] | Nullable A |
| List[A] | List of A |
| Set[A] | List of A |
| A => B | A and B |
| (A, B) | Object with 2 fields `_1` and `_2` |
| Either[A, B] | Object with 2 nullable fields `left` and `right` |
| Map[A, B] | List of Object with 2 fields `key` and `value` |
| ZIO[R, E, A] | Nullable A |
| ZStream[R, E, A] | A |
| Scala Type | GraphQL Type |
| ------------------ | ------------------------------------------------ |
| Boolean | Boolean |
| Int | Int |
| Float | Float |
| Double | Float |
| String | String |
| java.util.UUID | String |
| Unit | Unit (custom scalar) |
| Long | Long (custom scalar) |
| BigInt | BigInt (custom scalar) |
| BigDecimal | BigDecimal (custom scalar) |
| Case Class | Object |
| Sealed Trait | Enum or Union |
| Option[A] | Nullable A |
| List[A] | List of A |
| Set[A] | List of A |
| A => B | A and B |
| (A, B) | Object with 2 fields `_1` and `_2` |
| Either[A, B] | Object with 2 nullable fields `left` and `right` |
| Map[A, B] | List of Object with 2 fields `key` and `value` |
| ZIO[R, Nothing, A] | A |
| ZIO[R, E, A] | Nullable A |
| Future[A] | Nullable A |
| ZStream[R, E, A] | A |

See the [Custom Types](#custom-types) section to find out how to support your own types.

Expand Down