what to use resetStore or clearStore to reset apollo client cache? - apollo-client

please tell me what is the difference between resetStore and clearStore in the apollo client? what will happen to an already active request with clearReset?

Related

Best way to pass messages between 2 different protocol routes connected to same client

I have a http route /checkout which initiates a workflow process in Zeebe. The checkout route will return 200 response straight-away to calling client. Now, workflow will run for a while. So to push the response back to client after completion, I have a /sse separate route for server-sent events. Here, I will store all the client connection in a global map.
My doubt is how do I find the exact client to send the response back through sse once?
Example: Client A listening to /sse and calls /checkout endpoint which will return 200. The /sse has to return the response to client A after completion.
Currently, I thought of using cookie to identify the client. Is there a better way?
If you are already using cookies in your app than that's the way to go since the very purpose of cookies is identifying the client, so if you already have that, you should use it.
But if you rely on another authentication mechanism (like JWT), what you could do is using the url as a query.
So in the client instead of
let eventSource = new EventSource("/sse");
Do
let eventSource = new EventSource("/sse?authorization=jwt_token");
In the backend, you would validate that token, extract the Client ID and hit that global map with it to retrieve the corresponding connection.
(PS: instead of a global map, you should use a proper store, like redis, or an embedded key/value store like bbolt)

How could detect if client close the connection on rails 4.2

I am working on an API application on Rails 4.2.0. Wonder if there any way I could tell if the client closes the connection after they made API call to the server.
Tried session and cookie, seems they do not design for it.
Every HTTP requests ends up being closed when it's complete, as that's how the HTTP request-response cycle works. It's extremely rare to have connections hanging open as long-polling fell out of style once WebSocket was standardized.
After the client has made a call you can assume that request has completed and they've disconnected. There's no way of knowing if they will make additional requests or not, it's entirely up to the client.
In response to your comment on what you are actually trying to do, the only way I can think of would be via javascript using onunload. Here is a very basic example.
<body onunload="handleOnClose()">
<script>
function handleOnClose()
{
// send something to your backend
}
</script>
</body>
For more info see this SO question

Issue with MailChimp delete API?

For DELETE APIs, if we hit the API with invalid data, the API responds with proper error message. If we use the same HTTP connection object to hit another API, the request fails.
This issue is not seen for Create or Update APIs. Also if the Delete request is sent with valid data, then using the same HTTP connection object for next request works fine.
Please note that this behavior has implications for connection pooling in client applications, and we were just wondering if its known issue and if there is any available workaround.

grpc header/cookie in Go

I want to do place on server application which can be called by Go APP and Java app both.
for some reason ,there's a cookie authentication and oAuth mechanism ,so I want to set one Go app as Auth Micro-service for the authentication purpose.
As GRPC is built on the HTTP2 ,so The headers and cookies are on the protocol.but I did not find out how to carry on header and cookie when the rpc occurs,implemented by Go, on GitHub I only found the JAVA-Implementation for headers at :
https://github.com/grpc/grpc-java/tree/master/examples/src/main/java/io/grpc/examples/header
Can anybody give me some direction of Go implementation for this purpose?
Headers in gRPC are called "Metadata." Clients can only send "headers". Servers can send both "headers" and "trailers."
You want to:
Use the google.golang.org/grpc/metadata package and metadata.NewContext() to send metadata from the client-side.
Use grpc.SendHeader() and grpc.SetTrailer() to send metadata from the server-side.
Use the grpc.Header() and grpc.Trailer() CallOptions for receiving the Metadata on the client-side.
Use metadata.FromContext() for receiving metadata on the server-side.

Sinatra/Rack Sleep until Response Ready (like Exchange ActiveSync)

I'm wanting to do a lightweight push-style HTTP response in my existing Sinatra web app. Is there any mechanism that allows me to not respond to an HTTP request and keep the connection open until I wake up the connection at a future time?
You could also check out macournoyer's http://github.com/macournoyer/pusher "The Rack App that pushes" and collin's http://github.com/collin/orbited-ruby/
Could this help ?
http://macournoyer.com/blog/2009/06/04/pusher-and-async-with-thin/
Also, don't forget http://github.com/raggi/async_sinatra.

Resources