eventsourcing-graphql

Eventsourcing GraphQL adaptor

License

License

GroupId

GroupId

com.eventsourcing
ArtifactId

ArtifactId

eventsourcing-graphql
Last Version

Last Version

0.4.5
Release Date

Release Date

Type

Type

zip
Description

Description

eventsourcing-graphql
Eventsourcing GraphQL adaptor
Project URL

Project URL

https://github.com/eventsourcing/es4j-graphql
Source Code Management

Source Code Management

https://github.com/eventsourcing/es4j-graphql

Download eventsourcing-graphql

Dependencies

compile (18)

Group / Artifact Type Version
org.slf4j : slf4j-api jar 1.7.18
org.slf4j : slf4j-simple jar 1.7.18
com.google.guava : guava jar 19.0
org.reflections : reflections jar 0.9.10
org.projectlombok : lombok jar 1.16.8
org.osgi : org.osgi.core jar 6.0.0
org.osgi : org.osgi.service.cm jar 1.5.0
org.osgi : org.osgi.service.component jar 1.3.0
biz.aQute.bnd : biz.aQute.bndlib jar 3.1.0
com.eventsourcing : eventsourcing-core jar 0.4.4
javax.servlet : javax.servlet-api jar 3.1.0
com.graphql-java : graphql-java jar 2.2.0
com.graphql-java : graphql-java-annotations jar 0.13.0
com.graphql-java : graphql-java-servlet jar 0.8.0
com.fasterxml.jackson.core : jackson-core jar 2.7.2
com.fasterxml.jackson.core : jackson-annotations jar 2.7.2
com.fasterxml.jackson.core : jackson-databind jar 2.7.2
com.fasterxml.jackson.datatype : jackson-datatype-jdk8 jar 2.7.2

test (2)

Group / Artifact Type Version
org.testng : testng jar 6.9.10
org.mockito : mockito-core jar 1.10.19

Project Modules

There are no modules declared in this project.

Maven Central

ES4J (Eventsourcing for Java) GraphQL adaptor

This module implements a Relay.js-compatible GraphQL server intended to be used with ES4J commands. It also supports OSGi out of the box.

Downloading

You can download es4j-graphql from bintray (Gradle syntax):

repositories {
  mavenCentral()
}

dependencies {
  compile 'com.eventsourcing:eventsourcing-graphql:0.4.5'
}

Usage

The are a few important components this package provides (some of them come from graphql-java-servlet):

  • GraphQLQueryProvider/GraphQLMutationProvider interfaces. These will allow you to define which "domain model" views and which commands you are going to expose.
  • GraphQLServlet as an entry point servlet. Use bindQueryProvider/bindMutationProvider i or automatically wire them in OSGi.

Commands as mutations

@Accessors(fluent = true)
@GraphQLName("test")
@Value
public static class TestCommand extends StandardCommand<Void, String> {
    private String value;
}

There are two ways to expose such commands, one is to use PackageGrapgQLMutationProvider to scan all relevant packages to find subclasses of GraphQLCommand in those packages. For OSGi environments, BundleGraphQLMutationProvider should be used to scan relevant bundles.

Domain models as queries

public static class TestQueryProvider implements GraphQLQueryProvider {

    @GraphQLName("testObject")
    public static class TestObject {
        @GraphQLField
        public String field;
    }

    @Override @SneakyThrows
    public GraphQLObjectType getQuery() {
        return GraphQLAnnotations.object(Query.class);
    }

    @Override
    public Object context() {
        return new Query();
    }
}

Since it implements GraphQLQueryProvider, it can be bound to the servlet and will be automatically exposed as testObject { field }

com.eventsourcing

Eventsourcing, Inc.

Non-profit organization

Versions

Version
0.4.5
0.4.4
0.4.1
0.4.0