Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(query): add useQueriesState composable #35

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ElisePatrikainen
Copy link
Collaborator

No description provided.

Copy link

netlify bot commented Apr 28, 2024

Deploy Preview for funny-banoffee-0afb46 canceled.

Name Link
🔨 Latest commit 25a237f
🔍 Latest deploy log https://app.netlify.com/sites/funny-banoffee-0afb46/deploys/662e850dc698b600084c7585

@ElisePatrikainen ElisePatrikainen linked an issue Apr 28, 2024 that may be closed by this pull request
@@ -173,7 +173,7 @@ export const useQueryCache = defineStore(QUERY_STORE_ID, () => {

function ensureEntry<TResult = unknown, TError = ErrorDefault>(
keyRaw: EntryKey,
options: UseQueryOptionsWithDefaults<TResult, TError>,
options?: UseQueryOptionsWithDefaults<TResult, TError>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Creating a query entry without options risks errors if the key is invalidated and the options are accessed. Probably, we should consider avoiding creating query entities in UseQueryState and return undefined/null instead.

return keys.map<QueryState[]>(
// TODO: fix TS issue
(key) => {
const query = ensureEntry(toValue(key))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add and use the findQuery function here? It will work if we decide not to create a query in useQueriesState in case it has not been created

import type { QueryStatus } from './query-store'
import { useQueryCache } from './query-store'

interface QueryState {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use _UseQueryEntry_State type from query-store.ts here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Todo
Development

Successfully merging this pull request may close these issues.

add useQueryState()
2 participants