A library that lets you use Plain Old Java Objects to describe your GraphQL schema.
Example for Maven:
<dependency>
<groupId>com.nfl.glitr</groupId>
<artifactId>glitr</artifactId>
<version>x.y.z</version>
</dependency>
Example for gradle:
compile("com.nfl.glitr:glitr:x.y.z")
Change history can be found here: CHANGELOG.md
Add the repositories:
repositories {
maven { url "http://dl.bintray.com/nfl/maven" }
}
Dependency:
dependencies {
compile 'com.nfl.glitr:INSERT_LATEST_VERSION_HERE'
}
Add the repository:
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>bintray-nfl-maven</id>
<name>bintray</name>
<url>http://dl.bintray.com/nfl/maven</url>
</repository>
Dependency:
<dependency>
<groupId>com.nfl.glitr</groupId>
<artifactId>glitr</artifactId>
<version>INSERT_LATEST_VERSION_HERE</version>
</dependency>
This is the famous "hello world" in graphql-java with GLiTR:
import com.nfl.glitr.Glitr;
import com.nfl.glitr.GlitrBuilder;
import com.nfl.glitr.annotation.GlitrDescription;
import graphql.GraphQL;
import graphql.schema.DataFetchingEnvironment;
import java.util.Map;
public class HelloWorld {
public static void main(String[] args) {
Glitr glitr = GlitrBuilder.newGlitr()
.withQueryRoot(new Root())
.build();
GraphQL graphQL = new GraphQL(glitr.getSchema());
Map<String, Object> result = (Map<String, Object>) graphQL.execute("{hello}").getData();
System.out.println(result); // Prints: {hello=World!}
}
@GlitrDescription("Where it all begins.")
public static class Root {
public String getHello(DataFetchingEnvironment environment) {
return "World!";
}
}
}
See the Wiki for full documentation, examples, operational details and other information.
To build:
$ git clone [email protected]:NFL/glitr.git
$ cd glitr/
$ ./gradlew build
Further details on building can be found on the Getting Started page of the wiki.
-
= Java 8
See glitr-examples for example implementation
- Twitter: @nflengineers
- GitHub Issues
GLiTR is licensed under the MIT License. See LICENSE for more details.