@@ -76,9 +76,10 @@ export interface UseObjectQLMutationOptions {
7676 * ```
7777 */
7878export function useObjectQL ( options : UseObjectQLOptions ) : ObjectQLDataSource {
79+ const { baseUrl, token, spaceId } = options . config ;
7980 return useMemo (
80- ( ) => new ObjectQLDataSource ( options . config ) ,
81- [ options . config . baseUrl , options . config . token , options . config . spaceId ]
81+ ( ) => new ObjectQLDataSource ( { baseUrl , token , spaceId } ) ,
82+ [ baseUrl , token , spaceId ]
8283 ) ;
8384}
8485
@@ -127,14 +128,20 @@ export function useObjectQLQuery<T = any>(
127128 ...queryParams
128129 } = options ;
129130
131+ // Serialize params to string for stable dependency checking
132+ const queryParamsString = JSON . stringify ( queryParams ) ;
133+
130134 const fetchData = useCallback ( async ( ) => {
131135 if ( ! enabled ) return ;
132136
133137 setLoading ( true ) ;
134138 setError ( null ) ;
135139
136140 try {
137- const queryResult = await dataSource . find ( resource , queryParams ) ;
141+ // Parse params back from string to ensure we use the version
142+ // corresponding to the dependency trigger
143+ const params = JSON . parse ( queryParamsString ) ;
144+ const queryResult = await dataSource . find ( resource , params ) ;
138145 setResult ( queryResult ) ;
139146 setData ( queryResult . data ) ;
140147 onSuccess ?.( queryResult . data ) ;
@@ -145,7 +152,7 @@ export function useObjectQLQuery<T = any>(
145152 } finally {
146153 setLoading ( false ) ;
147154 }
148- } , [ dataSource , resource , enabled , onSuccess , onError , JSON . stringify ( queryParams ) ] ) ;
155+ } , [ dataSource , resource , enabled , onSuccess , onError , queryParamsString ] ) ;
149156
150157 useEffect ( ( ) => {
151158 fetchData ( ) ;
0 commit comments