Comments (5)
Are you implementing the 'Single connection mode' as documented in the protocol ? Or the 'Distinct connection mode' ?
I'm not very familiar with GraphQL over SSE or F# but in general it seems that:
-
The 'Distinct connection mode' would be extremely easy to implement, but suffers from the fact that clients cannot send authentication headers along with the HTTP request. I'd probably just override
GraphQLHttpMiddleware.HandleRequestAsync
and see if the HTTPAccept
header istext/event-stream
. If not, call the base method, otherwise, execute the request and tie the subscription responses to the response stream. Easy. No need to deal with any of the WebSocket handling classes at all.
Batched requests should be disabled in this scenario. -
The 'Single connection mode' could potentially reuse some of the functionality within
BaseSubscriptionServer
. One problem is that the message data type used isOperationMessage
, which is incompatible with the SSE protocol. However, it maintains its connection to the endpoint viaIOperationMessageProcessor
andIWebSocketConnection
. As such, the implementation ofWebSocketConnection
(which is what reads/writes messages to the WebSocket endpoint) could be rewritten to translate the messages in the protocol toOperationMessage
messages quite easily. You'd still have to write the code that match IDs to a dictionary of active connections and forwards the message for starting/stopping messages through, etc. Even so, it may be questionable as to how much of the code withinBaseSubscriptionServer
is practically reusable.
Looks like subscription implementation is hidden now
Well, it's not really hidden -- almost all of the classes are public. We have simply rewritten it from scratch and removed the dependencies on third party libraries such as System.Threading.Tasks.Dataflow
and System.Reactive
. It's also been integrated into the main project to simplify configuration.
There is a section within the readme that gives a brief overview of all of the subscription-related classes at the below link, and every method has descriptive XML comments. Feel free to ask if anything is unclear.
https://github.com/graphql-dotnet/server#websocket-handler-classes
from server.
Thanks for answering.
It should be 2) The 'Single connection mode'. I'll follow the section to see if I need to rewrite all the code.
I took a quick look at the code today, I need to write my own IWebSocketConnection
(maybe it should not rename to something more general?) and IOperationMessageProcessor
, could ReusableMemoryReaderStream
and AsyncMessagePump<T>
be public for easy extension?
from server.
@fallenwood Do you need more help here or we may close?
from server.
FYI, AsyncMessagePump is available within the Shane32.AsyncResetEvents nuget package
from server.
FYI, AsyncMessagePump is available within the Shane32.AsyncResetEvents nuget package
Thanks for the infos :)
@fallenwood Do you need more help here or we may close?
I am not working this area these days. I can close it, thanks for your help
from server.
Related Issues (20)
- Using Altair UI while not connected to the internet HOT 3
- Graphql playground trying to get schema from host url instead of whole application url. HOT 2
- Utilize Microsoft.NETFramework.ReferenceAssemblies
- Change project description HOT 1
- Badges HOT 2
- Deprecate dead packages HOT 2
- Authorization not working after upgrading to v6 HOT 5
- Deprecate support of the `application/graphql+json` media type HOT 2
- Change default response content type to match current draft spec
- [Feature] Add proper support of Accept HTTP header HOT 2
- Root Query Issue HOT 4
- Return 406 on unsupported Accept header
- Come up with something for comments about Accept header
- Question about upgrading from 6xx to 7xx: VoyagerOptions HOT 4
- Subscriptions set-up netcore 6.0, GraphQL 7.1.1 HOT 6
- HttpStatus Code on GRAPHQL_VALIDATION error HOT 6
- Is there a way to change the status code of the authorization extension from 400 to 401? HOT 10
- Validation rules and Policies errors after update to v7 HOT 11
- .net core 7 AddAuthorizationRule not work HOT 29
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 server.