Skip to content

Commit 4e96888

Browse files
committed
Make GQL initialize with callback
1 parent 55aed13 commit 4e96888

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

packages/app/src/app/overmind/dependencies/overmind-graphql.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ type Http = {
3838
options?: Options;
3939
};
4040

41-
type Ws = PhoenixSocket | null;
41+
type Ws = (() => PhoenixSocket) | null;
4242

4343
type Queries = {
4444
queries?: {
@@ -126,7 +126,7 @@ export const graphql: <T extends Queries>(
126126
let wsClient: PhoenixSocket | null = null;
127127
function getWsClient(): PhoenixSocket | null {
128128
if (_ws && !wsClient) {
129-
wsClient = withAbsintheSocket.create(_ws);
129+
wsClient = withAbsintheSocket.create(_ws());
130130
return wsClient;
131131
}
132132

packages/app/src/app/overmind/onInitialize.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,7 @@ export const onInitialize: OnInitialize = async (
3333
Authorization: `Bearer ${state.jwt}`,
3434
}),
3535
},
36-
// TODO(@christianalfoni): we need to make this dynamic, but overmind devtools can't serialize a socket with one channel.
37-
// Because of this the app crashes if we want to provide it with a function
38-
effects.jwt.get() ? effects.live.getSocket() : null
36+
() => effects.live.getSocket()
3937
);
4038

4139
effects.notifications.initialize({

0 commit comments

Comments
 (0)