File tree Expand file tree Collapse file tree 1 file changed +14
-13
lines changed
packages/angular/src/data-connect Expand file tree Collapse file tree 1 file changed +14
-13
lines changed Original file line number Diff line number Diff line change @@ -61,19 +61,20 @@ export function injectDataConnectQuery<Data, Variables>(
6161 Partial < QueryResult < Data , Variables > > | undefined
6262 > ( undefined ) ;
6363 const finalInjector = injector || inject ( EnvironmentInjector ) ;
64- const optionsSignal = computed ( ( ) =>
65- typeof queryRefOrOptionsFn === "function"
66- ? queryRefOrOptionsFn ( )
67- : undefined ,
68- ) ;
69- const queryRefSignal = computed ( ( ) =>
70- typeof queryRefOrOptionsFn === "function"
71- ? queryRefOrOptionsFn ( ) . queryFn ( )
72- : queryRefOrOptionsFn ,
73- ) ;
74- const varsSignal = computed ( ( ) =>
75- queryRefSignal ( ) . variables ,
76- ) ;
64+ const derivedOptions = computed ( ( ) => {
65+ if ( typeof queryRefOrOptionsFn === "function" ) {
66+ const options = queryRefOrOptionsFn ( ) ;
67+ const queryRef = options . queryFn ( ) ;
68+ return { options, queryRef } ;
69+ }
70+ return {
71+ options : undefined ,
72+ queryRef : queryRefOrOptionsFn as QueryRef < Data , Variables > ,
73+ } ;
74+ } ) ;
75+ const queryRefSignal = computed ( ( ) => derivedOptions ( ) . queryRef ) ;
76+ const optionsSignal = computed ( ( ) => derivedOptions ( ) . options ) ;
77+ const varsSignal = computed ( ( ) => derivedOptions ( ) . queryRef . variables ) ;
7778
7879 async function queryFn ( ) {
7980 const queryRef = queryRefSignal ( ) ;
You can’t perform that action at this time.
0 commit comments