Comments (7)
@ccamel That sounds like a good approach. It will force people to think about why they'd return nil
and we can add a doc string pointing at the spec.
from graphqlws.
You're referring to https://github.com/apollographql/subscriptions-transport-ws/blob/master/PROTOCOL.md#gql_data I assume. I agree, this is something we are not doing yet but should do.
from graphqlws.
That does look like it would solve my issue. I hope it can be merged as soon as possible.
from graphqlws.
The reason I haven't merged the subscription-listener
branch yet is that there already is way to achieve the same thing: by wrapping the default subscriptionManager
in your own SubscriptionManager
interface implementation and adding the "on connect" functionality to the AddSubscription
wrapper function.
I can see that this is not obvious and certainly not the prettiest solution. The subscription-listener
branch provides a more obvious way, so yes, let's move that branch forward.
Would it be reasonable to make it mandatory for listeners to return an initial gqlData
message back from SubscriptionAdded
? That would make it harder for users of graphqlws
to violate the GraphQL over WS spec. @ccamel, @alankm: What do you think?
from graphqlws.
@Jannis I get your point. As the SubscriptionManager
type is actually an interface, we could easily decorate it to introduce the functionality of "changes listening". However, I think it would greatly help users to have it available and ready to use in that library.
After having a good time on the subject, I think it's fine to have the SubscriptionAdded
callback to have a return value (a *DataMessagePayload
).
We can also accept the implementator to return a nil
value, for the sake of convenience, in such case the graphql payload returned (through the frame gqlData
) will be data: null
. Indeed, we may have the use case where the first data returned is empty (for instance if you want to subscribe to a Kafka topic which is empty).
from graphqlws.
@Jannis Won't the solution 2 proposed by @alankm be fixed by b829e73 in branch subscription-listener
? Do you plan to merge it soon?
from graphqlws.
@Jannis & @ccamel I'm all for this solution.
from graphqlws.
Related Issues (20)
- Implement GraphQL Websocket protocol basics
- Identify entities a subscription corresponds to
- Add authentication support
- Add authentication check on subsequent web socket messages HOT 1
- Add tests for the subscription manager
- Add GraphQL WebSocket starting point
- Add tests for the graphqlws handler
- Fix crash when trying to send data over an already closed connection
- Issues installing graphqlws with dep due to logrus dependency HOT 1
- Implement WebSocket connect management
- subscription.SendData does not include errors when sending JSON over websocket
- Needs a working pubsub example HOT 1
- Rare bug caused by concurrent map read and write HOT 2
- Allow to control logger
- Validate client subscriptions before adding them
- Data Race - Subscriptions not concurrent safe HOT 1
- Websock connection closing abnormally when running inside docker container
- Add subscriptions getter to SubscriptionManager
- Implement sending data to GraphQL WS clients
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from graphqlws.