• Stars
    star
    1,962
  • Rank 23,627 (Top 0.5 %)
  • Language
    Scala
  • License
    Apache License 2.0
  • Created over 9 years ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Scala GraphQL implementation

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 on the 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.

More Repositories

1

sangria-akka-http-example

An example GraphQL server written with akka-http, circe and sangria
Scala
241
star
2

sangria-subscriptions-example

An example of GraphQL akka-http server with stream-based subscriptions
Scala
169
star
3

sangria-relay

Sangria Relay Support
Scala
90
star
4

sangria-playground

An example of GraphQL server written with Play and sangria
JavaScript
87
star
5

sangria-slowlog

Sangria middleware to log slow GraphQL queries (with OpenTracing and apollo-tracing extension)
Scala
43
star
6

macro-visit

A macro-based generic visitor generator
Scala
24
star
7

sangria-circe

Sangria circe marshalling
Scala
24
star
8

sangria-play-json

Sangria play-json marshalling
Scala
20
star
9

sangria-federated

Running a sangria server as federated
Scala
18
star
10

sangria-relay-playground

An example of GraphQL server supporting Relay written with Play and sangria
HTML
17
star
11

sangria-monix

Sangria monix integration
Scala
10
star
12

sangria-akka-streams

Sangria akka-streams integration
Scala
10
star
13

sangria-graphql.github.io

Project website
CSS
6
star
14

sangria-msgpack

Sangria MessagePack marshalling.
Scala
5
star
15

sangria-spray-json

Sangria spray-json marshalling
Scala
3
star
16

sangria-ion

Sangria Amazon Ion marshalling
Scala
3
star
17

sangria-marshalling-api

Sangria Marshalling API
Scala
3
star
18

sangria-streaming-api

Sangria Streaming API
Scala
2
star
19

sangria-argonaut

Sangria argonaut marshalling
Scala
2
star
20

sangria-jackson

Sangria Jackson Marshalling (Without Json4s)
Scala
2
star
21

sangria-logo

The Logo
2
star
22

sangria-json4s-jackson

Sangria json4s-jackson marshalling
Scala
1
star
23

sangria-rxscala

Sangria RxScala integration
Scala
1
star
24

sangria-json4s-native

Sangria json4s-native marshalling
Scala
1
star