billybichon / liveGQL

Simple java library in order to use GraphQL Subscription on WebSocket based on Apollo Protocol.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Platform Technology License

This a simple java library in order to use GraphQL Subscription on WebSocket based on Apollo Protocol.

Features

  • connect to a GraphQL server
  • Handle init payload
  • Subscribe/Unsubscribe
  • Close connection
  • Error handling
  • Json handling
  • Manage generic types

Requirements

jdk version >= 1.8

iOS

You'll find the iOS version for this library here: iOS liveGQL

How to install

Gradle

dependency {
  compile 'com.github.billybichon:livegql:1.1'
}

maven

<dependency>
  <groupId>com.github.billybichon</groupId>
  <artifactId>livegql</artifactId>
  <version>1.1</version>
</dependency>

manually

Just copy the livegql-1.1.jar inside your libs folder and be sure to use:

dependency {
  compile fileTree(dir: 'libs', include: ['*.jar'])
}

How to use

Initialize
LiveGQL liveGQL = new LiveGQL("ws://your.url", new LiveGQLListener() {
    // override methods
  }
);
subscription
// subscribe
Subscription subscription = liveGQL.subscribe("query to subscribe", "tag");

// Unsubscribe
liveGQL.unsubscribe(subscription);
close connection
liveGQL.closeConnection();

Dependency

Libraries on which liveGQL depends:

  • Tyrus for managing websocket
  • Gson for handling json object

Bugs

  • Error are not handled but your app won't crash (because it's on the stream ;))

About

Simple java library in order to use GraphQL Subscription on WebSocket based on Apollo Protocol.

License:Other


Languages

Language:Java 100.0%