This a simple java library in order to use GraphQL Subscription on WebSocket based on Apollo Protocol.
- connect to a GraphQL server
- Handle init payload
- Subscribe/Unsubscribe
- Close connection
- Error handling
- Json handling
- Manage generic types
jdk version >= 1.8
You'll find the iOS version for this library here: iOS liveGQL
dependency {
compile 'com.github.billybichon:livegql:1.1'
}
<dependency>
<groupId>com.github.billybichon</groupId>
<artifactId>livegql</artifactId>
<version>1.1</version>
</dependency>
Just copy the livegql-1.1.jar
inside your libs folder and be sure to use:
dependency {
compile fileTree(dir: 'libs', include: ['*.jar'])
}
LiveGQL liveGQL = new LiveGQL("ws://your.url", new LiveGQLListener() {
// override methods
}
);
// subscribe
Subscription subscription = liveGQL.subscribe("query to subscribe", "tag");
// Unsubscribe
liveGQL.unsubscribe(subscription);
liveGQL.closeConnection();
Libraries on which liveGQL depends:
- Error are not handled but your app won't crash (because it's on the stream ;))