Skip to content

Latest commit

 

History

History
79 lines (53 loc) · 2.1 KB

README.md

File metadata and controls

79 lines (53 loc) · 2.1 KB

graphql-rxjava

This is an execution strategy for graphql-java that makes it easier to use rxjava's Observable. It currently requires Java8.

Build Status

Table of Contents

Rx Hello World

This is the famous "hello world" in graphql-rxjava:

import graphql.schema.GraphQLObjectType;
import graphql.schema.GraphQLSchema;

import graphql.execution.RxExecutionStrategy;
import graphql.execution.RxExecutionResult;

import static graphql.Scalars.GraphQLString;
import static graphql.schema.GraphQLFieldDefinition.newFieldDefinition;
import static graphql.schema.GraphQLObjectType.newObject;

public class HelloWorld {

    public static void main(String[] args) {

        GraphQLObjectType queryType = newObject()
                        .name("helloWorldQuery")
                        .field(newFieldDefinition()
                                .type(GraphQLString)
                                .name("hello")
                                .staticValue(Observable.just("world")))
                                .build())
                        .build();

        GraphQLSchema schema = GraphQLSchema.newSchema()
                        .query(queryType)
                        .build();

        Observable<?> result = ((RxExecutionResult)new GraphQL(schema, new RxExecutionStrategy()).execute("{hello}")).getDataObservable();

        result.subscribe(System.out::println);
        // Prints: {hello=world}
    }
}

Getting started with gradle

Make sure mavenCentral is among your repos:

repositories {
    mavenCentral()
}

Dependency:

dependencies {
  compile 'com.graphql-java:graphql-rxjava:0.0.1'
}

License

graphql-rxjava is licensed under the MIT License. See LICENSE for details.

Copyright (c) 2015, NFL and Contributors

graphql-js License