Skip to content
/ glitr Public

GLiTR - /ˈɡlɪtər/ POJO to GraphQL schema made easy

License

Notifications You must be signed in to change notification settings

nfl/glitr

Repository files navigation

GLiTR

Build Status Maven Central Download License

A library that lets you use Plain Old Java Objects to describe your GraphQL schema.

Binaries

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

How to use the latest build with Gradle

Add the repositories:

repositories {
    maven { url  "http://dl.bintray.com/nfl/maven" }
}

Dependency:

dependencies {
  compile 'com.nfl.glitr:INSERT_LATEST_VERSION_HERE'
}

How to use the latest build with Maven

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>

How to use it

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!";
        }
    }
}

Full Documentation

See the Wiki for full documentation, examples, operational details and other information.

Build

To build:

$ git clone git@github.com:NFL/glitr.git
$ cd glitr/
$ ./gradlew build

Further details on building can be found on the Getting Started page of the wiki.

Requirements

  • = Java 8

Examples

See glitr-examples for example implementation

Contact Info

LICENSE

GLiTR is licensed under the MIT License. See LICENSE for more details.