[server side] How do I implement and expose subscriptions?
See original GitHub issueAs mentioned in the question above. As far as I can tell, the resolvers for subscriptions should be implemented with the reactivestreams
Publisher
, but that does not seem to be the type shown in the generated interface. For example, I have
type Subscription {
testSub: Boolean!
}
If my understanding is correct, I’m expecting to implement a Publisher<Boolean>
, but right now I’m simply getting a normal Boolean
return type on the interface method.
Another related question: how do I expose the necessary websockets on the server side for these subscriptions? I have tried .subscriptionExecutionStrategy(new SubscriptionExecutionStrategy())
from here but it doesn’t seem to do anything different.
Thanks!
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Subscriptions in Apollo Server - Apollo GraphQL Docs
Subscriptions are long-lasting GraphQL read operations that can update their result whenever a particular server-side event occurs.
Read more >GraphQL Subscriptions: Why we use SSE/Fetch over ...
WunderGraph exposes GraphQL Subscriptions over SSE (Server-Sent Events) or Fetch (as a fallback). This post explains why we've decided to ...
Read more >Realtime GraphQL Subscriptions with Node.JS Tutorial
The goal is to implement two subscriptions to be exposed by your GraphQL server: Send realtime updates to subscribed clients when a new...
Read more >Using the HTTP Publish-Subscribe Server
Before you can perform any server-side tasks on the pub-sub server and its channels, you must first instantiate a PubSubServer object which represents...
Read more >GraphQL subscriptions - Relay
GraphQL subscriptions are a mechanism to allow clients to query for data in response to a stream of server-side events. ... Note that...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Sorry, at first I thought you just needed to return async type.
in sbt plugin you can use option
apiAsyncReturnType
such asalso can use in gradle plugin
if resultType is
Collection
, useapiAsyncReturnListType
but if you want use in subscription
you can use
subscriptionReturnType
like
also can use in gradle plugin
when you exec task, will generate java code
hi @kobylynskyi apologies for the very late reply, but thanks, I did implement the GraphQLSubscriptionResolver similarly for my testing. may I know if the websocket exposure needs to be implemented explicitly? If I understand Java correctly, websockets are implemented through http anyway, so I should think there is no further need to do anything else, but I am not able to hit the subscription WS endpoint in my GraphQL playground.
Not sure if this issue is related to the application.yml settings (I’m actually using application.properties, I understand they are basically equivalent) being only in the latest version? For my purposes, I’m currently using the codegen 2.0.0.
Would appreciate any further advice. Thank you!