Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
tusharmath committed Jul 17, 2022
0 parents commit 74731ed
Show file tree
Hide file tree
Showing 10 changed files with 129 additions and 0 deletions.
32 changes: 32 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# macOS
.DS_Store

# sbt specific
dist/*
target/
lib_managed/
src_managed/
project/boot/
project/plugins/project/
project/local-plugins.sbt
.history
.ensime
.ensime_cache/
.sbt-scripted/
local.sbt

# Bloop
.bsp

# VS Code
.vscode/

# Metals
.bloop/
.metals/
metals.sbt

# IDEA
.idea
.idea_modules
/.worksheet/
22 changes: 22 additions & 0 deletions .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
align.multiline = true
align.preset = more
align.stripMargin = true
assumeStandardLibraryStripMargin = true
continuationIndent.defnSite = 2
danglingParentheses.preset = true
docstrings = JavaDoc
docstrings.style = Asterisk
docstrings.wrap = yes
docstrings.wrapMaxColumn = 80
includeCurlyBraceInSelectChains = false
lineEndings = preserve
maxColumn = 120
newlines.afterInfix = keep
optIn.annotationNewlines = true
rewrite.imports.sort = original
rewrite.rules = [Imports, RedundantBraces, SortModifiers]
rewrite.rules = [RedundantParens]
runner.dialect = scala213
spaces.inImportCurlyBraces = false
trailingCommas = "always"
version = "3.5.3"
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
## sbt project compiled with Scala 3

### Usage

This is a normal sbt project. You can compile code with `sbt compile`, run it with `sbt run`, and `sbt console` will start a Scala 3 REPL.

For more information on the sbt-dotty plugin, see the
[scala3-example-project](https://github.com/scala/scala3-example-project/blob/main/README.md).
17 changes: 17 additions & 0 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import Dependencies._

val scala3Version = "2.13.8"

lazy val root = project
.in(file("."))
.settings(
name := "GraphQLCompose",
version := "0.1.0-SNAPSHOT",
scalaVersion := scala3Version,
libraryDependencies := Seq(
ZIOCore,
ZIOSchema,
ZIOSchemaDerivation,
ZIOTest % Test,
),
)
10 changes: 10 additions & 0 deletions project/Dependencies.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
object Dependencies {
import sbt._
val zioVersion = "2.0.0"
val zioSchemaVersion = "0.2.0"

val ZIOCore = "dev.zio" %% "zio" % zioVersion
val ZIOTest = "dev.zio" %% "zio-test" % zioVersion
val ZIOSchema = "dev.zio" %% "zio-schema" % zioSchemaVersion
val ZIOSchemaDerivation = "dev.zio" %% "zio-schema-derivation" % zioSchemaVersion
}
1 change: 1 addition & 0 deletions project/build.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sbt.version=1.7.1
8 changes: 8 additions & 0 deletions src/main/scala/com/tusharmath/compose/Endpoint.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.tusharmath.compose

final case class Endpoint(host: String, port: Int, path: String, body: Array[Byte], protocol: Protocol)

sealed trait Protocol
object Protocol {
case class Http(method: String) extends Protocol
}
15 changes: 15 additions & 0 deletions src/main/scala/com/tusharmath/compose/GraphQL.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.tusharmath.compose

import zio.schema.Schema

sealed trait GraphQL[-A, +B] {}

object GraphQL {
case class Constant[B](b: B, schema: Schema[B]) extends GraphQL[Any, B]
case class Identity[A](schema: Schema[A]) extends GraphQL[A, A]
case class Compose[A, B, C](g: GraphQL[B, C], f: GraphQL[A, B]) extends GraphQL[A, C]
case class Zip2[A, B, C](g: GraphQL[A, B], f: GraphQL[A, C]) extends GraphQL[A, (B, C)]
case class Load[A](endpoint: Endpoint, schema: Schema[A]) extends GraphQL[Any, A]

def constant[A](a: A)(implicit schema: Schema[A]): GraphQL[Any, A] = Constant(a, schema)
}
7 changes: 7 additions & 0 deletions src/main/scala/com/tusharmath/compose/Main.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.tusharmath.compose

object Main extends App {
def hello(): Unit = {
println("Hello!")
}
}
9 changes: 9 additions & 0 deletions src/test/scala/com/tusharmath/compose/GraphQLSpec.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.tusharmath.compose

import com.tusharmath.compose.GraphQLSpec.test
import zio.test.{assertTrue, ZIOSpecDefault}

object GraphQLSpec extends ZIOSpecDefault:
override def spec = test("Some test") {
assertTrue(true)
}

0 comments on commit 74731ed

Please sign in to comment.