Skip to content

Instantly share code, notes, and snippets.

View tehpsalmist's full-sized avatar
🚑
move things and breakfast

Ben Steward tehpsalmist

🚑
move things and breakfast
View GitHub Profile
@tehpsalmist
tehpsalmist / .useApolloClient.md
Last active March 12, 2024 11:08
Refreshing Apollo subscription websocket connections with updated auth tokens

useApolloClient

The primary idea of this hook is to re-create the underlying ApolloClient being used by all of the Subscription and Query components. There is lots of talk throughout the Apollo community about how to best refresh a WebSocket connection when a new auth token is available, and this is my attempt at providing something useful, apart from middleware that seems to have issues.

Related Links

const chokidar = require('chokidar')
const { exec } = require('child_process')
const frontend = chokidar.watch([
'./plugins/**/*',
'./maya.json'
], { ignored: ['./plugins/*/node_modules', './plugins/*/build/**.*'] })
frontend.on('ready', () => console.log('I am at your service, my liege.'))