-
Notifications
You must be signed in to change notification settings - Fork 96
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
support for subscriptions #309
Comments
Hello @markhamnr, Subscriptions are supported—we are using them in our implementation. This support is not directly related to graphql-java-annotations but rather to graphql-java. However, I agree that this specific case lacks documentation and examples. I'll try to help: 1. WebSocket EndpointFirst, you need a WebSocket endpoint to receive subscription requests. You can find an example in our implementation: 2. Base Schema EndpointYou also need a base schema endpoint to register your subscriptions: @GraphQLName("Subscription")
public static class Subscription {
} 3. Subscription Implementation ExampleHere’s an example of a Subscription implementation: A key part that might be missing on your side is that the Publisher should carry a GraphQL object, like this: Publisher<GqlWorkflowEvent> Where @GraphQLField
@GraphQLDescription("Workflow that has just been started")
public GqlWorkflow getStartedWorkflow() {
return startedWorkflow;
} Hope this helps! Feel free to explore the repository—it’s public and serves as the GraphQL API for our project. 🚀 |
OK, this is about the simplest example I can come up with: https://gist.github.com/markhamnr/7a516ef640f353791165ef3f75478eae When run, it gives me the |
Am I wrong in thinking that subscriptions aren't supported currently?
The README implies that they are, or at least it mentions registering a Subscription class as well as a Query class and a Mutation class.
But I can't see any examples, nor can I get it to work myself. The GraphQL Java site says that a subscription should return a Publisher, but when I try that with
AnnotationsSchemaCreator
I get anInvalidSchemaException
: "Publisher" must define one or more fields.Is there a way to handle subscriptions I haven't figure out yet? Or if not, is this something that could be added?
The text was updated successfully, but these errors were encountered: