Skip to content

Getting Started

Arash Shokoufandeh edited this page Oct 25, 2016 · 21 revisions

Contents

  1. Getting the Binaries
  2. Hello World
  3. Build It
  4. Running the Tests

#Getting Started

Getting the 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")

Hello World

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

Build it

To build:

$ git clone [email protected]:NFL/glitr.git
$ cd glitr/
$ ./gradlew build

Running the Tests

$ ./gradlew test
Clone this wiki locally