Last active
November 14, 2019 01:59
-
-
Save duanebester/40eb438a943b53a5e1108f3b05746f9a to your computer and use it in GitHub Desktop.
Main Scala App - 0
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object Main extends App { | |
val PORT = 8080 | |
implicit val actorSystem = ActorSystem("graphql-server") | |
implicit val materializer = ActorMaterializer() | |
import actorSystem.dispatcher | |
scala.sys.addShutdownHook(() -> shutdown()) | |
val route: Route = | |
(post & path("graphql")) { | |
entity(as[JsValue]) { requestJson => | |
complete("GraphQL") | |
} | |
} ~ { | |
getFromResource("graphiql.html") | |
} | |
Http().bindAndHandle(route, "0.0.0.0", PORT) | |
println(s"GraphiQL Available at: http://localhost:$PORT") | |
def shutdown(): Unit = { | |
actorSystem.terminate() | |
Await.result(actorSystem.whenTerminated, 30 seconds) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment