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

Export createUseQueryOptions and createUseInfiniteQueryOptions from the library #327

Closed
lsmurray opened this issue Jan 31, 2024 · 3 comments

Comments

@lsmurray
Copy link

First off, thank you for all the work you've put into this package!

I would like to propose some use cases for createUseQueryOptions and createUseInfiniteQueryOptions as a continuation of the conversation from #296.

// fetching a list of suspense queries
const suspenseQueries = useSuspenseQueries({
  queries: userIds.map((userId) =>
    createUseQueryOptions(getUser, { userId }, { transport })
  ),
});

// fetching a list of standard queries
const queries = useQueries({
  queries: userIds.map((userId) =>
    createUseQueryOptions(getUser, { userId }, { transport })
  ),
});

// ensuring a query is loaded
await queryClient.ensureQueryData(
  createUseQueryOptions(getUser, { userId: 1 }, { transport })
);

// prefetching a query
queryClient.prefetchQuery(
  createUseQueryOptions(getUser, { userId: 1 }, { transport })
);

So far I do not have a use case for createUseInfiniteQueryOptions but other people may need createUseInfiniteQueryOptions for these same use cases, specifically prefetching and ensuring a query is loaded.

I can use createConnectQueryKey and callUnaryMethod to build my own createUseQueryOptions but once I've made that code typesafe and reusable its basically a copy of the internal methods.

@paul-sachs
Copy link
Collaborator

Let's keep the conversation within the original issue of #296 to keep things focused. It may turn out to make sense to expose these APIs but I'd like to keep the discussion in one place.

@paul-sachs
Copy link
Collaborator

paul-sachs commented Feb 27, 2024

After further discussions with the team, we've decided to reexport createQueryOptions and createInfiniteQueryOptions. I feel like we'll definitely want a more opinionated useQueries and other APIs but if this unblocks users, then it's valuable. It'll be available in the next release (see #343).

@lsmurray
Copy link
Author

thank you - I had rewritten both in my project. Really appreciate it and looking forward to the more opinionated APIs when they are available!

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

No branches or pull requests

2 participants