Skip to content

Commit

Permalink
fix: allow only PageableRequest for infinite hooks to filter at least…
Browse files Browse the repository at this point in the history
… it's page and pageSize...
  • Loading branch information
melistik committed Sep 14, 2023
1 parent 8e382be commit bd9375d
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@ export function {{ method.hookName -}}<TData = {{ method.shortReturnType }}, TEr
...options
});
{% elseif method.hookType equals "infinite" %}
export function {{ method.hookName -}}<TData = {{ method.shortReturnType }}, TError = unknown>({% if method.hasRequiredFields or method.hasOptionalFields %}filter: {{ method.shortInputType }},{% endif %} options: Omit<UseInfiniteQueryOptions<{{ method.shortReturnType }}, TError, TData>, "queryFn" | "queryKey" | "getPreviousPageParam" | "getNextPageParam"> = {}) {
export function {{ method.hookName -}}<TData = {{ method.shortReturnType }}, TError = unknown>({% if method.hasRequiredFields or method.hasOptionalFields %}filter: {{ method.shortInputType }},{% elseif method.fieldsExtendsPaging %}filter: PageableRequest,{% endif %} options: Omit<UseInfiniteQueryOptions<{{ method.shortReturnType }}, TError, TData>, "queryFn" | "queryKey" | "getPreviousPageParam" | "getNextPageParam"> = {}) {
const { {{ configuredGroupVar }} } = useApi();
return useInfiniteQuery<{{ method.shortReturnType }}, TError, TData>(
{
queryKey: [{% for ck in method.cacheKeysPrepared('filter.') %}`{{ck}}`{% if not loop.last %}, {% endif %}{% endfor %}{% if method.hasRequiredFields or method.hasOptionalFields %}, filter {% endif %}],
queryFn: ({ pageParam, signal }) => {{ configuredGroupVar -}}.{{- controller.fieldName -}}.{{- method.methodName -}}({ {% if method.hasRequiredFields or method.hasOptionalFields %}...filter, {% endif %}{{ infiniteParams( method ) }}, overrides: { signal } }),
queryFn: ({ pageParam, signal }) => {{ configuredGroupVar -}}.{{- controller.fieldName -}}.{{- method.methodName -}}({ {% if method.hasRequiredFields or method.hasOptionalFields or method.fieldsExtendsPaging %}...filter, {% endif %}{{ infiniteParams( method ) }}, overrides: { signal } }),
{% if method.staleTime is not null and method.staleTime > 0 %}staleTime: {{ method.staleTime }} * 1000, {% endif %}
...options,
{{ infiniteOptions( method ) }}
Expand Down

0 comments on commit bd9375d

Please sign in to comment.