Skip to content
This repository was archived by the owner on Sep 27, 2023. It is now read-only.

Commit 39aecfd

Browse files
committed
use captured generics for options
1 parent f26cb4c commit 39aecfd

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

src/hooks.ts

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -208,16 +208,16 @@ export function usePaginated${n}(fragmentRef: any) {
208208

209209
function makePreloadedQueryBlock(name: string) {
210210
const n = capitalize(name);
211-
return `export function usePreloaded${n}(preloadedQuery: PreloadedQuery<${name}>, options?: {
212-
UNSTABLE_renderPolicy?: RenderPolicy;
213-
}) {
211+
return `type PreloadedQueryOptions = Parameters<typeof usePreloadedQuery>[2];
212+
213+
export function usePreloaded${n}(preloadedQuery: PreloadedQuery<${name}>, options?: PreloadedQueryOptions) {
214214
return usePreloadedQuery<${name}>(node, preloadedQuery, options)
215215
}`;
216216
}
217217

218218
function makeQueryLoaderBlock(name: string) {
219-
const fn = capitalize(name);
220-
return `export function use${fn}Loader(initialQueryReference?: PreloadedQuery<${name}> | null) {
219+
const n = capitalize(name);
220+
return `export function use${n}Loader(initialQueryReference?: PreloadedQuery<${name}> | null) {
221221
return useQueryLoader(node, initialQueryReference)
222222
}`;
223223
}
@@ -228,14 +228,11 @@ function makeLazyLoadBlock(
228228
) {
229229
const n = capitalize(name);
230230
const noVars = args.length === 0;
231-
return `export function use${n}(variables: VariablesOf<${name}>${
231+
return `type LazyLoadOptions = Parameters<typeof useLazyLoadQuery>[2];
232+
233+
export function use${n}(variables: VariablesOf<${name}>${
232234
noVars ? " = {}" : ""
233-
}, options?: {
234-
fetchKey?: string | number;
235-
fetchPolicy?: FetchPolicy;
236-
networkCacheConfig?: CacheConfig;
237-
UNSTABLE_renderPolicy?: RenderPolicy;
238-
}) {
235+
}, options?: LazyLoadOptions) {
239236
return useLazyLoadQuery<${name}>(node, variables, options)
240237
}`;
241238
}

0 commit comments

Comments
 (0)