• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

sangria-graphql/sangria: Scala GraphQL implementation

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

sangria-graphql/sangria

开源软件地址(OpenSource Url):

https://github.com/sangria-graphql/sangria

开源编程语言(OpenSource Language):

Scala 99.9%

开源软件介绍(OpenSource Introduction):

Sangria Logo

Sangria is a scala GraphQL library.

Continuous Integration Coverage Status Maven Central License Scaladocs Join the chat at https://gitter.im/sangria-graphql/sangria

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 Example

In 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, Ideas

If 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.

StackOverflow

In case you need some help or support, then you can use StackOverflow for this. When you are asking a question, be sure to add scala, graphql and sangria tags, so that other people can easily find them.

Gitter & Mailing List

For more general, lengthy discussions or pretty much anything else please join us in the gitter chat and google groups.

Contribute

If 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!

License

Sangria is licensed under Apache License, Version 2.0.




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap