Skip to content

Commit fbefe3f

Browse files
committed
moved caliban to scala
1 parent b862ff0 commit fbefe3f

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
name: Caliban
3+
description: Functional GraphQL library for Scala, with client code generation and type-safe queries.
4+
url: https://ghostdogpr.github.io/caliban/
5+
github: ghostdogpr/caliban
6+
---
7+
8+
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
name: Caliban
3+
description: Caliban is a purely functional library for building GraphQL servers and clients in Scala
4+
url: https://ghostdogpr.github.io/caliban/
5+
github: ghostdogpr/caliban
6+
---
7+
8+
An example of a GraphQL schema and query with `caliban`:
9+
```scala
10+
case class Character(name: String, age: Int)
11+
def getCharacters(): List[Character] = ???
12+
// schema
13+
case class Queries(characters: List[Character])
14+
// resolver
15+
val queries = Queries(getCharacters)
16+
import caliban.GraphQL.graphQL
17+
import caliban.RootResolver
18+
val api = graphQL(RootResolver(queries))
19+
for {
20+
interpreter <- api.interpreter
21+
} yield interpreter
22+
case class GraphQLResponse[+E](data: ResponseValue, errors: List[E])
23+
val query = """
24+
{
25+
characters {
26+
name
27+
}
28+
}"""
29+
for {
30+
result <- interpreter.execute(query)
31+
_ <- zio.console.putStrLn(result.data.toString)
32+
} yield ()
33+
```

0 commit comments

Comments
 (0)