File tree 1 file changed +11
-15
lines changed
src/content/code/language-support/scala/server
1 file changed +11
-15
lines changed Original file line number Diff line number Diff line change @@ -7,27 +7,23 @@ github: ghostdogpr/caliban
7
7
8
8
An example of a GraphQL schema and query with ` caliban ` :
9
9
``` scala
10
+ import caliban .GraphQL .graphQL
11
+ import caliban .RootResolver
12
+
10
13
case class Character (name : String , age : Int )
14
+
11
15
def getCharacters (): List [Character ] = ???
16
+
12
17
// schema
13
18
case class Queries (characters : List [Character ])
19
+
14
20
// resolver
15
21
val queries = Queries (getCharacters)
16
- import caliban .GraphQL .graphQL
17
- import caliban .RootResolver
18
- val api = graphQL(RootResolver (queries))
22
+
23
+ val query = " { characters { name } }"
19
24
for {
25
+ api = graphQL(RootResolver (queries))
20
26
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 ()
27
+ result <- interpreter.execute(query)
28
+ } yield result
33
29
```
You can’t perform that action at this time.
0 commit comments