• Stars
    star
    241
  • Rank 167,643 (Top 4 %)
  • 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

An example GraphQL server written with akka-http, circe and sangria

Sangria akka-http Example

An example GraphQL server written with akka-http, circe and sangria.

Deploy

After starting the server with

sbt run

# or, if you want to watch the source code changes
 
sbt ~reStart

you can run queries interactively using graphql-playground by opening http://localhost:8080 in a browser or query the /graphql endpoint directly. The HTTP endpoint follows GraphQL best practices for handling the HTTP requests.

Here are some examples of the queries you can make:

$ curl -X POST localhost:8080/graphql \
  -H "Content-Type:application/json" \
  -d '{"query": "{hero {name, friends {name}}}"}'

this gives back the hero of StarWars Saga together with the list of his friends, which is of course R2-D2:

{
  "data": {
    "hero": {
      "name": "R2-D2",
      "friends": [
        {
          "name": "Luke Skywalker"
        },
        {
          "name": "Han Solo"
        },
        {
          "name": "Leia Organa"
        }
      ]
    }
  }
}

Here is another example, which uses variables:

$ curl -X POST localhost:8080/graphql \
  -H "Content-Type:application/json" \
  -d '{"query": "query Test($humanId: String!){human(id: $humanId) {name, homePlanet, friends {name}}}", "variables": {"humanId": "1000"}}'

The result should be something like this:

{
  "data": {
    "human": {
      "name": "Luke Skywalker",
      "homePlanet": "Tatooine",
      "friends": [
        {
          "name": "Han Solo"
        },
        {
          "name": "Leia Organa"
        },
        {
          "name": "C-3PO"
        },
        {
          "name": "R2-D2"
        }
      ]
    }
  }
}

More Repositories

1

sangria

Scala GraphQL implementation
Scala
1,962
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