useInfinateQuery not passing in { take, skip } #1448
Answered
by
flybayer
lewisblackburn
asked this question in
Q&A
-
useInfiniteQuery not passing in { take, skip }Asking this at the risk of sounding dumb, I was looking at the docs on how to use the InfiniteQuery hook and copied the code straight over, however, I realised that it was pulling all the data and wasn't taking
const [movies, { isFetching, isFetchingMore, fetchMore, canFetchMore }] = useInfiniteQuery(
getMovies,
(page = { take: 1, skip: 0 }) => page,
{
getFetchMore: (lastGroup) => lastGroup.nextPage,
}
)
console.log(movies, movies[0].movies)
import db, { FindManyMovieArgs } from "db"
type GetMoviesInput = Pick<FindManyMovieArgs, "where" | "orderBy" | "skip" | "take">
export default async function getMovies(
{ where, orderBy, skip = 0, take }: GetMoviesInput,
ctx: Ctx
) {
ctx.session.authorize()
const movies = await db.movie.findMany({
where,
orderBy,
take,
skip,
})
const count = await db.movie.count()
const hasMore = typeof take === "number" ? skip + take < count : false
const nextPage = hasMore ? { take, skip: skip + take! } : null
return {
movies,
nextPage,
hasMore,
count,
}
} |
Beta Was this translation helpful? Give feedback.
Answered by
flybayer
Nov 10, 2020
Replies: 1 comment 2 replies
-
|
What blitz version are you on? There was a bug with this on v0.25.0-canary.1 that's fixed in v0.25.0-canary.2 |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
lewisblackburn
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What blitz version are you on?
There was a bug with this on v0.25.0-canary.1 that's fixed in v0.25.0-canary.2