feat: add skipToken support for conditional query execution#13
Open
antomorel wants to merge 1 commit into
Open
feat: add skipToken support for conditional query execution#13antomorel wants to merge 1 commit into
antomorel wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds first-class skipToken support to the Effect-based React Query hooks/utilities so callers can idiomatically skip conditional queries using TanStack Query’s skipToken, while also re-exporting skipToken from this package.
Changes:
- Re-export
skipTokenfrom@tanstack/react-queryvia the library entrypoint. - Extend hook/option types and hook implementations to accept
skipTokenas aqueryFn. - Add tests covering skip/conditional-skip behavior and type-level constraints.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 13 comments.
Show a summary per file
| File | Description |
|---|---|
src/index.ts |
Re-exports skipToken from TanStack Query. |
src/types.ts |
Updates public option/result types to allow skipToken as a queryFn. |
src/useEffectQuery.ts |
Adds runtime handling for skipToken when calling useQuery. |
src/useInfiniteEffectQuery.ts |
Adds runtime handling for skipToken when calling useInfiniteQuery (including getNextPageParam handling). |
src/useEffectQueries.ts |
Adds per-query skipToken handling when mapping to useQueries inputs. |
src/toQueryOptions.ts |
Adds skipToken support when converting Effect query options to React Query options. |
test/useEffectQuery.test.ts |
Adds skipToken behavior + type-level tests for useEffectQuery. |
test/useInfiniteEffectQuery.test.ts |
Adds skipToken behavior + type-level tests for useInfiniteEffectQuery. |
test/useEffectQueries.test.ts |
Adds skipToken behavior + type-level tests for useEffectQueries. |
test/effectQueryOptions.test.ts |
Adds skipToken tests for effectQueryOptions. |
.changeset/add-skip-token.md |
Declares a minor release and documents the new skipToken feature. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
f5ed401 to
cb46299
Compare
d84f558 to
94cc1f1
Compare
Comment on lines
12
to
19
| type EffectQueryOptionsBase = { | ||
| queryKey: QueryKey; | ||
| queryFn: (...args: any[]) => Effect.Effect<any, any, any>; | ||
| runtime?: Runtime.Runtime<any> | ManagedRuntime.ManagedRuntime<any, any> | undefined; | ||
| queryFn: ((...args: any[]) => Effect.Effect<any, any, any>) | SkipToken; | ||
| runtime?: | ||
| | Runtime.Runtime<any> | ||
| | ManagedRuntime.ManagedRuntime<any, any> | ||
| | undefined; | ||
| }; |
Comment on lines
95
to
98
| const result = useQueries({ | ||
| queries: transformedQueries, | ||
| queries: transformedQueries as any, | ||
| combine: options.combine as (result: Array<any>) => TCombinedResult, | ||
| }); |
Comment on lines
+65
to
+70
| if (queryFn === skipToken) { | ||
| return { | ||
| ...restOptions, | ||
| queryFn: skipToken, | ||
| }; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
skipTokenfrom@tanstack/react-queryfor convenienceuseEffectQuery,useInfiniteEffectQuery,useEffectQueries) now acceptskipTokenasqueryFntoQueryOptionsandeffectQueryOptionssupportskipTokenfor use withuseQuerydirectlyskipToken, theruntimeoption is not required (typed asnever)This enables the idiomatic TanStack Query pattern for conditional queries:
Changes
SkipTokenvs Effect queryFn