Git Product home page Git Product logo

sangria's 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 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.

sangria's People

Contributors

asteinwedel avatar bc-dima-pasieka avatar dispalt avatar dlreeves avatar fehu avatar filosganga avatar jchyb avatar jonas avatar joprice avatar jsoref avatar jtjeferreira avatar keirlawson avatar maloku avatar mattfenwick avatar maxperrimond avatar msolomon avatar nickhudkins avatar nightscape avatar nikola-mladenovic avatar ocordsen avatar olegilyenko avatar performantdata avatar scala-steward avatar sh0hei avatar simonadameit avatar stefanolande avatar travisbrown avatar vishalkuo avatar windymelt avatar yanns avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sangria's Issues

Find better way to handle arguments

  • Introduce a type class for argument mapping
    • This type class should define unmarshaling mechanism
  • OptionType should result in Option arg value

How does `Projection` handle Union & Interface types?

Hi,

I'm working on a Ruby GraphQL implementation and I'm exploring options for supporting efficient database queries. I really like your Projection approach and I've given it a try.

The problem I have is, what about Interfaces and Unions? In order to resolve the type, you need the object. But projection happens before getting the objects themselves.

I've been reading through your project but I must say Scala is a bit over my head :S Can you point me towards your solution for this issue, if you have one?

Thanks!

Change semantics of `Projector`

  • Give it all collected fields, bot only marked as Projection
  • Projection now allows to customize the name
  • NoProjection allows to remove field from projections list
  • Projectior allows to specify how deep it should look (the level arg)

gitter channel ?

Hi,
How about having a gitter channel for this repo ..

Steps :
login to u r gitter account
-> create Room
-> choose Repository
-> done (gitter will send a automated PR )

screen shot 2015-06-25 at 8 12 12 am

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.