Skip to content

Commit 82c2b0a

Browse files
OlegIlyenkoleebyron
authored andcommitted
Scala example (graphql#82)
1 parent da02bb3 commit 82c2b0a

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

site/code/index.html.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,25 @@ There are also nice bindings for [Relay](https://facebook.github.io/relay/), Dja
201201
202202
### Scala
203203
204-
- [Sangria](http://sangria-graphql.org/) ([github](https://github.com/sangria-graphql/sangria)): A Scala GraphQL library that supports [Relay](https://facebook.github.io/relay/).
204+
#### [Sangria](http://sangria-graphql.org/) ([github](https://github.com/sangria-graphql/sangria)): A Scala GraphQL library that supports [Relay](https://facebook.github.io/relay/).
205+
206+
An example of a hello world GraphQL schema and query with \`sangria\`:
207+
208+
\`\`\`scala
209+
import sangria.schema._
210+
import sangria.execution._
211+
import sangria.macros._
212+
213+
val QueryType = ObjectType("Query", fields[Unit, Unit](
214+
Field("hello", StringType, resolve = _ ⇒ "Hello world!")
215+
))
216+
217+
val schema = Schema(QueryType)
218+
219+
val query = graphql"{ hello }"
220+
221+
Executor.execute(schema, query) map println
222+
\`\`\`
205223
206224
### Java
207225

0 commit comments

Comments
 (0)