File tree Expand file tree Collapse file tree 2 files changed +41
-0
lines changed
src/content/code/language-support/scala Expand file tree Collapse file tree 2 files changed +41
-0
lines changed Original file line number Diff line number Diff line change
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
+
Original file line number Diff line number Diff line change
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
+ ```
You can’t perform that action at this time.
0 commit comments