-
Notifications
You must be signed in to change notification settings - Fork 2k
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
ws Network Interface Integration #272
Comments
This is something that I'm interested in as well. A few thoughts below, not as fleshed out as yours at the moment. I'd propose I can't say that I'm a fan of the I think the request and response messages should be structured the same. Each would have My hope is that code in I'm unclear about the use-case for the diffing that you mentioned. |
Very nice! I wanted to point out one extra advantage of using ws for graphql: Since the connection remain live for a long time, you only need to verify the user session once, so that saves on a bunch of database lookups. |
Keep in mind you have some other mechanism to invalidate the WebSocket connection should the user's session become invalid for some reason. |
Hi, I've tried to review how can i support the current subscription manager for the new approach. return {
context: {},
schema: Schema,
engine: new SubscriptionManagerEngine({ pubsub, setupFunctions }),
}; the idea is to do the new in a static location and not inside a callback which calls every time ofcourse. this way we can support this approach for legacy users who wants to switch, CC: |
@DxCx I'm having a little trouble fitting the pieces together. I presume the need for this would be to support |
Well, the engine should export a reactive execution function. Which gets the same parameters as execute but returns an observable interface. Usig this aproach, in the future we can write an executaion engine that supports the reactive directives, for now only subscription will be supported by the same interface as subscription manager as i exampled above |
I like most of your proposal here @DxCx. 🙂 I think it's fine to keep the same interface for the websocket server as we did for the other servers until we see a need to change it. For the websocket protocol, I agree with @NeoPhi that we should just extend (and maybe harmonize) what we already have for subscriptions. So messages both to and from the server should have
Maybe we also need some sort of keepalive / heartbeat message to keep the socket connection open. As for actually executing the GraphQL query on the server, I assume that this will eventually be taken care of by graphql-js entirely, but for now we should have our own engine (I prefer to call it |
See apollographql#272 for more info.
@DxCx Thinking more about sending diffs, I would suggest using an implementation that adheres to RFC6902 aka JSON Patch. There are many conforming implementations which would give the server and client a choice of the implementation to use. |
nice! thanks @NeoPhi i didn't know this format, |
See apollographql#272 for more info.
hey @helfer
how do you want to tackle those? align
|
See apollographql#272 for more info.
See apollographql#272 for more info.
See apollographql#272 for more info.
See apollographql#272 for more info.
@DxCx hey, any news on graphql queries over ws support? |
@vladshcherbin @MrGekko |
Closing this for now as we've gone into a different direction for now 🤷♂️ |
Hi All,
I've been speaking with @helfer and we got into agreement that i should add a pure websocket integration.
before writing anything, i want to post here some mini-design to share my thoughts and hear some feedback.
package name: i was thinking about
graphql-server-ws
, then the function will be calledgraphqlWs
.how to use it:
So, i don't see any reason why not having the same interface as our other packages, therefore:
NOTE: One more options is to do the multiplexing internally, but it breaks abit the similarity to other interfaces, and it will look like:
underlaying protocol:
so, as i can see it, there is no much difference between using HTTP POST as a transport, or a websocket.
the main difference are:
to solve this, i suggest to add the following fields to request:
id
field - shall be used to respond.action
field - one of the following values:when used,
query
,variables
andoperationName
will be used.id
field is being used.also, the response should also add response type and id, so it will look like:
therefore, if we request a query with 1 result,
the server will send:
but if we request a query with more then 1 result, the server can send diff updates,
and the client can construct the full immutable object over and over.
how diffing will be done:
i really liked the deep-diff library,
so i'm thinking of using it and keep the diff as is at the moment.
This is more or less what i had on my mind,
feel free to comment and give feedback :)
The text was updated successfully, but these errors were encountered: