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

Toto #23

Closed
wants to merge 5 commits into from
Closed

Toto #23

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
13 changes: 13 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,19 @@ on:
branches: ["*"]

jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: coursier/cache-action@v6
- uses: actions/[email protected]
with:
distribution: temurin
java-version: 11
check-latest: true
- name: Run scalafix and scalafmt
run: sbt ';scalafixAll --check ;scalafmtCheckAll '

ci:
runs-on: ubuntu-latest
steps:
Expand Down
4 changes: 2 additions & 2 deletions .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#version = "3.0.6"
runner.dialect = scala212
version = "3.0.6"
runner.dialect = Scala213Source3 # https://scalameta.org/scalafmt/docs/configuration.html#scala-2-with--xsource3
maxColumn = 140
align.preset = most
continuationIndent.defnSite = 2
Expand Down
3 changes: 0 additions & 3 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import BuildHelper._
import Libraries._
import sbt.librarymanagement.Resolver

Global / onChangedBuildSource := ReloadOnSourceChanges

Expand All @@ -18,8 +17,6 @@ ThisBuild / scalafixScalaBinaryVersion := CrossVersion.binaryScalaVersion(scalaV
ThisBuild / scalafixDependencies ++= List(
"com.github.vovapolu" %% "scaluzzi" % "0.1.20"
)
ThisBuild / resolvers += Resolver.mavenLocal
ThisBuild / resolvers += Resolver.sonatypeRepo("snapshots")

// ### App Modules ###

Expand Down
5 changes: 2 additions & 3 deletions modules/app/src/main/scala/poc/caliban/app/Main.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import zio.magic._
import zio.{ExitCode, Has, RIO, URIO, ZEnv, ZManaged}

object Main extends zio.App {
import org.http4s.implicits._
import zio.interop.catz._

type R = ZEnv with Has[PostService]
Expand All @@ -20,10 +19,10 @@ object Main extends zio.App {
interpreter <- ZManaged.fromEffect(poc.caliban.posts.GraphQLApi.api.interpreter)
_ <- BlazeServerBuilder[LocalTask]
.bindHttp(8080, "0.0.0.0")
.withHttpApp(
.withHttpWebSocketApp(builder =>
Router[LocalTask](
"/api/graphql" -> Http4sAdapter.makeHttpService(interpreter),
"/ws/graphql" -> Http4sAdapter.makeWebSocketService(interpreter),
"/ws/graphql" -> Http4sAdapter.makeWebSocketService(builder, interpreter),
"/graphiql" -> HttpRoutes.liftF(StaticFile.fromResource("/graphiql.html", None))
).orNotFound
)
Expand Down
103 changes: 103 additions & 0 deletions modules/caliban-clients/src/main/scala/generated/Client.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
package generated

import caliban.client.FieldBuilder._
import caliban.client._
import caliban.client.__Value._

object Client {

type ID = String

type AuthorName
object AuthorName {
def name: SelectionBuilder[AuthorName, String] = _root_.caliban.client.SelectionBuilder.Field("name", Scalar())
}

type PostId
object PostId {
def id: SelectionBuilder[PostId, String] = _root_.caliban.client.SelectionBuilder.Field("id", Scalar())
}

type PostContent
object PostContent {
def content: SelectionBuilder[PostContent, String] = _root_.caliban.client.SelectionBuilder.Field("content", Scalar())
}

type PostTitle
object PostTitle {
def title: SelectionBuilder[PostTitle, String] = _root_.caliban.client.SelectionBuilder.Field("title", Scalar())
}

type Post
object Post {
def id[A](innerSelection: SelectionBuilder[PostId, A]): SelectionBuilder[Post, A] =
_root_.caliban.client.SelectionBuilder.Field("id", Obj(innerSelection))
def author[A](innerSelection: SelectionBuilder[AuthorName, A]): SelectionBuilder[Post, A] =
_root_.caliban.client.SelectionBuilder.Field("author", Obj(innerSelection))
def title[A](innerSelection: SelectionBuilder[PostTitle, A]): SelectionBuilder[Post, A] =
_root_.caliban.client.SelectionBuilder.Field("title", Obj(innerSelection))
def content[A](innerSelection: SelectionBuilder[PostContent, A]): SelectionBuilder[Post, A] =
_root_.caliban.client.SelectionBuilder.Field("content", Obj(innerSelection))
}

case class PostContentInput(content: String)
object PostContentInput {
implicit val encoder: ArgEncoder[PostContentInput] = new ArgEncoder[PostContentInput] {
override def encode(value: PostContentInput): __Value =
__ObjectValue(List("content" -> implicitly[ArgEncoder[String]].encode(value.content)))
}
}
case class AuthorNameInput(name: String)
object AuthorNameInput {
implicit val encoder: ArgEncoder[AuthorNameInput] = new ArgEncoder[AuthorNameInput] {
override def encode(value: AuthorNameInput): __Value =
__ObjectValue(List("name" -> implicitly[ArgEncoder[String]].encode(value.name)))
}
}
case class PostTitleInput(title: String)
object PostTitleInput {
implicit val encoder: ArgEncoder[PostTitleInput] = new ArgEncoder[PostTitleInput] {
override def encode(value: PostTitleInput): __Value =
__ObjectValue(List("title" -> implicitly[ArgEncoder[String]].encode(value.title)))
}
}
type Query = _root_.caliban.client.Operations.RootQuery
object Query {
def postById[A](id: String)(innerSelection: SelectionBuilder[Post, A])(implicit
encoder0: ArgEncoder[String]
): SelectionBuilder[_root_.caliban.client.Operations.RootQuery, Option[A]] = _root_.caliban.client.SelectionBuilder
.Field("postById", OptionOf(Obj(innerSelection)), arguments = List(Argument("id", id, "ID!")(encoder0)))
}

type Mutation = _root_.caliban.client.Operations.RootMutation
object Mutation {
def createPost[A](authorName: AuthorNameInput, title: PostTitleInput, content: PostContentInput)(
innerSelection: SelectionBuilder[Post, A]
)(implicit
encoder0: ArgEncoder[AuthorNameInput],
encoder1: ArgEncoder[PostTitleInput],
encoder2: ArgEncoder[PostContentInput]
): SelectionBuilder[_root_.caliban.client.Operations.RootMutation, Option[A]] = _root_.caliban.client.SelectionBuilder.Field(
"createPost",
OptionOf(Obj(innerSelection)),
arguments = List(
Argument("authorName", authorName, "AuthorNameInput!")(encoder0),
Argument("title", title, "PostTitleInput!")(encoder1),
Argument("content", content, "PostContentInput!")(encoder2)
)
)
def deletePost(
id: String
)(implicit encoder0: ArgEncoder[String]): SelectionBuilder[_root_.caliban.client.Operations.RootMutation, Option[Unit]] =
_root_.caliban.client.SelectionBuilder.Field("deletePost", OptionOf(Scalar()), arguments = List(Argument("id", id, "ID!")(encoder0)))
}

type Subscription = _root_.caliban.client.Operations.RootSubscription
object Subscription {
def allPostsByAuthor[A](name: String)(innerSelection: SelectionBuilder[Post, A])(implicit
encoder0: ArgEncoder[String]
): SelectionBuilder[_root_.caliban.client.Operations.RootSubscription, Option[A]] = _root_.caliban.client.SelectionBuilder
.Field("allPostsByAuthor", OptionOf(Obj(innerSelection)), arguments = List(Argument("name", name, "String!")(encoder0)))
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
package poc.caliban.client.generated.posts

import caliban.client.FieldBuilder._
import caliban.client._
import caliban.client.__Value._

object CalibanClient {

type ID = String

type AuthorName
object AuthorName {
def name: SelectionBuilder[AuthorName, String] = _root_.caliban.client.SelectionBuilder.Field("name", Scalar())
}

type PostId
object PostId {
def id: SelectionBuilder[PostId, String] = _root_.caliban.client.SelectionBuilder.Field("id", Scalar())
}

type PostContent
object PostContent {
def content: SelectionBuilder[PostContent, String] = _root_.caliban.client.SelectionBuilder.Field("content", Scalar())
}

type PostTitle
object PostTitle {
def title: SelectionBuilder[PostTitle, String] = _root_.caliban.client.SelectionBuilder.Field("title", Scalar())
}

type Post
object Post {
def id[A](innerSelection: SelectionBuilder[PostId, A]): SelectionBuilder[Post, A] =
_root_.caliban.client.SelectionBuilder.Field("id", Obj(innerSelection))
def author[A](innerSelection: SelectionBuilder[AuthorName, A]): SelectionBuilder[Post, A] =
_root_.caliban.client.SelectionBuilder.Field("author", Obj(innerSelection))
def title[A](innerSelection: SelectionBuilder[PostTitle, A]): SelectionBuilder[Post, A] =
_root_.caliban.client.SelectionBuilder.Field("title", Obj(innerSelection))
def content[A](innerSelection: SelectionBuilder[PostContent, A]): SelectionBuilder[Post, A] =
_root_.caliban.client.SelectionBuilder.Field("content", Obj(innerSelection))
}

case class PostContentInput(content: String)
object PostContentInput {
implicit val encoder: ArgEncoder[PostContentInput] = new ArgEncoder[PostContentInput] {
override def encode(value: PostContentInput): __Value =
__ObjectValue(List("content" -> implicitly[ArgEncoder[String]].encode(value.content)))
}
}
case class AuthorNameInput(name: String)
object AuthorNameInput {
implicit val encoder: ArgEncoder[AuthorNameInput] = new ArgEncoder[AuthorNameInput] {
override def encode(value: AuthorNameInput): __Value =
__ObjectValue(List("name" -> implicitly[ArgEncoder[String]].encode(value.name)))
}
}
case class PostTitleInput(title: String)
object PostTitleInput {
implicit val encoder: ArgEncoder[PostTitleInput] = new ArgEncoder[PostTitleInput] {
override def encode(value: PostTitleInput): __Value =
__ObjectValue(List("title" -> implicitly[ArgEncoder[String]].encode(value.title)))
}
}
type Query = _root_.caliban.client.Operations.RootQuery
object Query {
def postById[A](id: String)(innerSelection: SelectionBuilder[Post, A])(implicit
encoder0: ArgEncoder[String]
): SelectionBuilder[_root_.caliban.client.Operations.RootQuery, Option[A]] = _root_.caliban.client.SelectionBuilder
.Field("postById", OptionOf(Obj(innerSelection)), arguments = List(Argument("id", id, "ID!")(encoder0)))
}

type Mutation = _root_.caliban.client.Operations.RootMutation
object Mutation {
def createPost[A](authorName: AuthorNameInput, title: PostTitleInput, content: PostContentInput)(
innerSelection: SelectionBuilder[Post, A]
)(implicit
encoder0: ArgEncoder[AuthorNameInput],
encoder1: ArgEncoder[PostTitleInput],
encoder2: ArgEncoder[PostContentInput]
): SelectionBuilder[_root_.caliban.client.Operations.RootMutation, Option[A]] = _root_.caliban.client.SelectionBuilder.Field(
"createPost",
OptionOf(Obj(innerSelection)),
arguments = List(
Argument("authorName", authorName, "AuthorNameInput!")(encoder0),
Argument("title", title, "PostTitleInput!")(encoder1),
Argument("content", content, "PostContentInput!")(encoder2)
)
)
def deletePost(
id: String
)(implicit encoder0: ArgEncoder[String]): SelectionBuilder[_root_.caliban.client.Operations.RootMutation, Option[Unit]] =
_root_.caliban.client.SelectionBuilder.Field("deletePost", OptionOf(Scalar()), arguments = List(Argument("id", id, "ID!")(encoder0)))
}

type Subscription = _root_.caliban.client.Operations.RootSubscription
object Subscription {
def allPostsByAuthor[A](name: String)(innerSelection: SelectionBuilder[Post, A])(implicit
encoder0: ArgEncoder[String]
): SelectionBuilder[_root_.caliban.client.Operations.RootSubscription, Option[A]] = _root_.caliban.client.SelectionBuilder
.Field("allPostsByAuthor", OptionOf(Obj(innerSelection)), arguments = List(Argument("name", name, "String!")(encoder0)))
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package poc.caliban.client.generated.posts.splitted

import caliban.client.FieldBuilder._
import caliban.client._

object AuthorName {
def name: SelectionBuilder[AuthorName, String] = _root_.caliban.client.SelectionBuilder.Field("name", Scalar())
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package poc.caliban.client.generated.posts.splitted

import caliban.client._
import caliban.client.__Value._

case class AuthorNameInput(name: String)
object AuthorNameInput {
implicit val encoder: ArgEncoder[AuthorNameInput] = new ArgEncoder[AuthorNameInput] {
override def encode(value: AuthorNameInput): __Value =
__ObjectValue(List("name" -> implicitly[ArgEncoder[String]].encode(value.name)))
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package poc.caliban.client.generated.posts.splitted

import caliban.client.FieldBuilder._
import caliban.client._

object Mutation {
def createPost[A](authorName: AuthorNameInput, title: PostTitleInput, content: PostContentInput)(
innerSelection: SelectionBuilder[Post, A]
)(implicit
encoder0: ArgEncoder[AuthorNameInput],
encoder1: ArgEncoder[PostTitleInput],
encoder2: ArgEncoder[PostContentInput]
): SelectionBuilder[_root_.caliban.client.Operations.RootMutation, Option[A]] = _root_.caliban.client.SelectionBuilder.Field(
"createPost",
OptionOf(Obj(innerSelection)),
arguments = List(
Argument("authorName", authorName, "AuthorNameInput!")(encoder0),
Argument("title", title, "PostTitleInput!")(encoder1),
Argument("content", content, "PostContentInput!")(encoder2)
)
)
def deletePost(
id: String
)(implicit encoder0: ArgEncoder[String]): SelectionBuilder[_root_.caliban.client.Operations.RootMutation, Option[Unit]] =
_root_.caliban.client.SelectionBuilder.Field("deletePost", OptionOf(Scalar()), arguments = List(Argument("id", id, "ID!")(encoder0)))
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package poc.caliban.client.generated.posts.splitted

import caliban.client.FieldBuilder._
import caliban.client._

object Post {
def id[A](innerSelection: SelectionBuilder[PostId, A]): SelectionBuilder[Post, A] =
_root_.caliban.client.SelectionBuilder.Field("id", Obj(innerSelection))
def author[A](innerSelection: SelectionBuilder[AuthorName, A]): SelectionBuilder[Post, A] =
_root_.caliban.client.SelectionBuilder.Field("author", Obj(innerSelection))
def title[A](innerSelection: SelectionBuilder[PostTitle, A]): SelectionBuilder[Post, A] =
_root_.caliban.client.SelectionBuilder.Field("title", Obj(innerSelection))
def content[A](innerSelection: SelectionBuilder[PostContent, A]): SelectionBuilder[Post, A] =
_root_.caliban.client.SelectionBuilder.Field("content", Obj(innerSelection))
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package poc.caliban.client.generated.posts.splitted

import caliban.client.FieldBuilder._
import caliban.client._

object PostContent {
def content: SelectionBuilder[PostContent, String] = _root_.caliban.client.SelectionBuilder.Field("content", Scalar())
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package poc.caliban.client.generated.posts.splitted

import caliban.client._
import caliban.client.__Value._

case class PostContentInput(content: String)
object PostContentInput {
implicit val encoder: ArgEncoder[PostContentInput] = new ArgEncoder[PostContentInput] {
override def encode(value: PostContentInput): __Value =
__ObjectValue(List("content" -> implicitly[ArgEncoder[String]].encode(value.content)))
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package poc.caliban.client.generated.posts.splitted

import caliban.client.FieldBuilder._
import caliban.client._

object PostId {
def id: SelectionBuilder[PostId, String] = _root_.caliban.client.SelectionBuilder.Field("id", Scalar())
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package poc.caliban.client.generated.posts.splitted

import caliban.client.FieldBuilder._
import caliban.client._

object PostTitle {
def title: SelectionBuilder[PostTitle, String] = _root_.caliban.client.SelectionBuilder.Field("title", Scalar())
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package poc.caliban.client.generated.posts.splitted

import caliban.client._
import caliban.client.__Value._

case class PostTitleInput(title: String)
object PostTitleInput {
implicit val encoder: ArgEncoder[PostTitleInput] = new ArgEncoder[PostTitleInput] {
override def encode(value: PostTitleInput): __Value =
__ObjectValue(List("title" -> implicitly[ArgEncoder[String]].encode(value.title)))
}
}
Loading