T
TanStack4y ago
absent-sapphire

Call queryFn outside query expects meta

I'm using the query key implementation described here : https://tkdodo.eu/blog/leveraging-the-query-function-context#object-query-keys alongside the initialData NextJS strategy (so fetching the first page in getStaticProps then using the props to initialize query (infinite in this case). Since the queryKey is passed into the queryFn and destructured in the queryFn implementation I now get a warning that meta is missing when simply calling
fetchTodos({
queryKey:todoKeys.list(profileId)
})
fetchTodos({
queryKey:todoKeys.list(profileId)
})
Is there anything wrong with calling the queryFn with undefined meta in this case? ie - am i overwriting anything RQ fills into the meta or is meta for user-land info only
fetchTodos({
queryKey: todoKeys.list(profileId),
meta: undefined
})
fetchTodos({
queryKey: todoKeys.list(profileId),
meta: undefined
})
thanks!
Leveraging the Query Function Context
Use what React Query provides for optimal type safety
2 Replies
judicial-coral
judicial-coral4y ago
yeah so if fetchTodos has the interface of a queryFn (it takes a QueryFunctionContext), then meta is required, but can be undefined. I've defined meta this way because for react-query, it would be wrong to call this function without passing meta, which is what I wanted to avoid
absent-sapphire
absent-sapphireOP4y ago
awesome. Thanks! Just wanted to be sure i wasn't overwriting/preventing any default meta info from being part of the infiniteQuery.

Did you find this page helpful?