@@ -172,15 +172,12 @@ type PodResult = {
172172} ;
173173
174174export interface RuntimeSlice {
175- apolloClient ?: ApolloClient < any > ;
176- setApolloClient : ( client : ApolloClient < any > ) => void ;
177-
178175 parsePod : ( id : string ) => void ;
179176 parseAllPods : ( ) => void ;
180177 resolvePod : ( id ) => void ;
181178 resolveAllPods : ( ) => void ;
182- yjsRun : ( id : string ) => void ;
183- yjsRunChain : ( id : string ) => void ;
179+ yjsRun : ( id : string , apolloClient : ApolloClient < any > ) => void ;
180+ yjsRunChain : ( id : string , apolloClient : ApolloClient < any > ) => void ;
184181 clearResults : ( id ) => void ;
185182 setRunning : ( id ) => void ;
186183 parseResult : Record <
@@ -196,16 +193,14 @@ export interface RuntimeSlice {
196193 getResultMap ( ) : Y . Map < PodResult > ;
197194 activeRuntime ?: string ;
198195 setActiveRuntime ( id ?: string ) : void ;
199- yjsSendRun ( ids : string [ ] ) : void ;
196+ yjsSendRun ( ids : string [ ] , apolloClient : ApolloClient < any > ) : void ;
200197 isRuntimeReady ( ) : boolean ;
201198}
202199
203200export const createRuntimeSlice : StateCreator < MyState , [ ] , [ ] , RuntimeSlice > = (
204201 set ,
205202 get
206203) => ( {
207- apolloClient : undefined ,
208- setApolloClient : ( client ) => set ( { apolloClient : client } ) ,
209204 parseResult : { } ,
210205
211206 // new yjs-based runtime
@@ -306,7 +301,7 @@ export const createRuntimeSlice: StateCreator<MyState, [], [], RuntimeSlice> = (
306301 }
307302 return true ;
308303 } ,
309- yjsSendRun ( ids ) {
304+ yjsSendRun ( ids , apolloClient ) {
310305 const activeRuntime = get ( ) . activeRuntime ! ;
311306 let specs = ids . map ( ( id ) => {
312307 // Actually send the run request.
@@ -337,7 +332,7 @@ export const createRuntimeSlice: StateCreator<MyState, [], [], RuntimeSlice> = (
337332 return false ;
338333 } ) ;
339334 if ( specs ) {
340- get ( ) . apolloClient ? .mutate ( {
335+ apolloClient . mutate ( {
341336 mutation : gql `
342337 mutation RunChain($specs: [RunSpecInput], $runtimeId: String) {
343338 runChain(specs: $specs, runtimeId: $runtimeId)
@@ -353,21 +348,21 @@ export const createRuntimeSlice: StateCreator<MyState, [], [], RuntimeSlice> = (
353348 } ) ;
354349 }
355350 } ,
356- yjsRun : ( id ) => {
351+ yjsRun : ( id , apolloClient ) => {
357352 if ( ! get ( ) . isRuntimeReady ( ) ) return ;
358353 const nodesMap = get ( ) . getNodesMap ( ) ;
359354 const nodes = Array . from < Node > ( nodesMap . values ( ) ) ;
360355 const node = nodesMap . get ( id ) ;
361356 if ( ! node ) return ;
362357 const chain = getDescendants ( node , nodes ) ;
363- get ( ) . yjsSendRun ( chain ) ;
358+ get ( ) . yjsSendRun ( chain , apolloClient ) ;
364359 } ,
365360 /**
366361 * Add the pod and all its downstream pods (defined by edges) to the chain and run the chain.
367362 * @param id the id of the pod to start the chain
368363 * @returns
369364 */
370- yjsRunChain : async ( id ) => {
365+ yjsRunChain : async ( id , apolloClient ) => {
371366 if ( ! get ( ) . isRuntimeReady ( ) ) return ;
372367 // Get the chain: get the edges, and then get the pods
373368 const edgesMap = get ( ) . getEdgesMap ( ) ;
@@ -387,7 +382,7 @@ export const createRuntimeSlice: StateCreator<MyState, [], [], RuntimeSlice> = (
387382 chain . push ( nodeid ) ;
388383 nodeid = node2target [ nodeid ] ;
389384 }
390- get ( ) . yjsSendRun ( chain ) ;
385+ get ( ) . yjsSendRun ( chain , apolloClient ) ;
391386 } ,
392387 clearResults : ( id ) => {
393388 const resultMap = get ( ) . getResultMap ( ) ;
0 commit comments