- Notifications
You must be signed in to change notification settings - Fork220
Scala GraphQL implementation
License
sangria-graphql/sangria
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Sangria is a scalaGraphQL 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 outSangria 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 withreact-relay framework, then you also may be interested insangria-relay.
Sangria is a spec compliant GraphQL implementation, so it works out of the box withApollo,Relay,GraphiQL and other GraphQL tools and libraries.
In this example we will usecirce 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:
importsangria.schema._importsangria.execution._importsangria.macros._importsangria.marshalling.circe._importscala.concurrent.ExecutionContext.Implicits.globalvalQueryType=ObjectType("Query", fields[Unit,Unit](Field("hello",StringType, resolve= _=>"Hello world!")))valschema=Schema(QueryType)valquery=graphql"{ hello }"valresult=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 theGetting Started Tutorial.
If you've got some interesting ideas to share or discovered a nasty bug, feel free to useSangria'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 usethis minimal gist as a template.
In case you need some help or support, then you can useStackOverflow for this.When you areasking a question,be sure to addscala
,graphql
andsangria
tags, so that other people can easily find them.
For more general, lengthy discussions or pretty much anything else please join us in thegitter chat.
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 tothe documentation or help others by answering questions onStackOverflow or joining discussions on thegitter 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!
Sangria is licensed underApache License, Version 2.0.
About
Scala GraphQL implementation