在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):sangria-graphql/sangria开源软件地址(OpenSource Url):https://github.com/sangria-graphql/sangria开源编程语言(OpenSource Language):Scala 99.9%开源软件介绍(OpenSource Introduction):Sangria is a scala GraphQL library. SBT Configuration: libraryDependencies += "org.sangria-graphql" %% "sangria" % "<latest version>" You can find an example application that uses akka-http with sangria here: https://github.com/sangria-graphql/sangria-akka-http-example More info and the documentation can be found in the project home page: https://sangria-graphql.github.io/ I would also recommend you to check out Sangria Playground. It is an example of GraphQL server written with Play framework and Sangria. It also serves as a playground, where you can interactively execute GraphQL queries and play with some examples. If you want to use sangria with react-relay framework, then you also may be interested in sangria-relay. Sangria is a spec compliant GraphQL implementation, so it works out of the box with Apollo, Relay, GraphiQL and other GraphQL tools and libraries. Hello World ExampleIn this example we will use circe JSON marshalling, so we also need to include following dependency: libraryDependencies += "org.sangria-graphql" %% "sangria-circe" % "1.3.2" The most simple Hello World application might look like this: import sangria.schema._
import sangria.execution._
import sangria.macros._
import sangria.marshalling.circe._
import scala.concurrent.ExecutionContext.Implicits.global
val QueryType = ObjectType("Query", fields[Unit, Unit](
Field("hello", StringType, resolve = _ => "Hello world!")
))
val schema = Schema(QueryType)
val query = graphql"{ hello }"
val result = Executor.execute(schema, query)
result.foreach(res => println(res.spaces2)) this example will print following result JSON: {
"data" : {
"hello" : "Hello world!"
}
} For more complex example, I would recommend you to check out the Getting Started Tutorial. Issues, Bugs, IdeasIf you've got some interesting ideas to share or discovered a nasty bug, feel free to use Sangria's issue tracker. Also feel free to fork project and create the pull requests - they are highly appreciated! If you are facing an issue and not sure what would be the best way to describe it, the I would recommend you to use this minimal gist as a template. StackOverflowIn case you need some help or support, then you can use StackOverflow for this.
When you are asking a question,
be sure to add Gitter & Mailing ListFor more general, lengthy discussions or pretty much anything else please join us in the gitter chat and google groups. ContributeIf you like the project and would like to support it or contribute to it, then you are very welcome to do so. You can spread the word and tweet about the project or even better - create a small blog post, video, example project and show how you use sangria and GraphQL. I'm pretty sure it would be interesting for many people. Also you can contribute to the documentation or help others by answering questions on StackOverflow or joining discussions at the mailing list and gitter chat. It would be very helpful! Not to mention the code itself. There is nothing more exciting than hacking some stuff together :) So please feel free to materialize your ideas in form of code and send pull requests! LicenseSangria is licensed under Apache License, Version 2.0. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论