Skip to content

Library for writing GraphQL servers with subscription support

License

Notifications You must be signed in to change notification settings

peterholak/graphql-ws-kotlin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

46 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

graphql-ws-kotlin

Unfinished / work in progress, but should be somewhat usable! Feedback welcome.

Example demo: http://graphql.holak.net/


This library makes it easy to write GraphQL servers that support subscriptions via WebSockets. It uses graphql-java to execute GraphQL queries.

The protocol for subscriptions is taken from apollographql/subscriptions-transport-ws, which you can use as a client (see the frontend in example/src/main/resources/frontend).

Getting started

Run the example

Use the library

For now, there is no released version, so you can only use the current snapshot. Add the jitpack.io repository to your build.gradle.

repositories {
    maven { url "https://jitpack.io" }
}

Then add the dependency

compile 'com.github.peterholak:graphql-ws-kotlin:-SNAPSHOT'

What still needs to be done

  • improved documentation, code examples in README
  • more robust exception handling (consistent/predictable behavior no matter where an exception occurs)
  • more logging
  • performance improvements
    • currently, it runs the subscription query for every subscriber, even if the query is the same
    • support for batching notifications would be nice
    • as far as I can tell, variables are also needlessly coerced into the correct type on every publish() (it is sufficient to do this just once)
    • use asynchronous GraphQL query execution in publish()
  • thread safety
  • tests for more cases (especially write tests where the stubs currently are)
  • the setup is still a bit too complicated, untangle the cyclical dependencies (see Main.kt in the example project)
  • maybe support for writing clients (including Kotlin JS target)
  • all the other TODOs in the code (other operations, keep-alive, etc.)
  • javadoc for most of the classes
  • maybe support for using method arguments in filters, instead of using maps (see the publish for filteredPublishedText in the example project)

About

Library for writing GraphQL servers with subscription support

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages