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: expose pagination: false to REST / GraphQL #9952

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/graphql/src/resolvers/collections/find.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export type Resolver = (
limit?: number
locale?: string
page?: number
pagination?: boolean
sort?: string
where?: Where
},
Expand Down Expand Up @@ -53,6 +54,7 @@ export function findResolver(collection: Collection): Resolver {
draft: args.draft,
limit: args.limit,
page: args.page,
pagination: args.pagination,
req,
sort: args.sort,
where: args.where,
Expand Down
2 changes: 2 additions & 0 deletions packages/graphql/src/resolvers/collections/findVersions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export type Resolver = (
limit?: number
locale?: string
page?: number
pagination?: boolean
sort?: string
where: Where
},
Expand Down Expand Up @@ -50,6 +51,7 @@ export function findVersionsResolver(collection: Collection): Resolver {
depth: 0,
limit: args.limit,
page: args.page,
pagination: args.pagination,
req: isolateObjectProperty(req, 'transactionID'),
sort: args.sort,
where: args.where,
Expand Down
2 changes: 2 additions & 0 deletions packages/graphql/src/resolvers/globals/findVersions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export type Resolver = (
limit?: number
locale?: string
page?: number
pagination?: boolean
sort?: string
where: Where
},
Expand All @@ -26,6 +27,7 @@ export function findVersions(globalConfig: SanitizedGlobalConfig): Resolver {
globalConfig,
limit: args.limit,
page: args.page,
pagination: args.pagination,
req: isolateObjectProperty(context.req, 'transactionID'),
sort: args.sort,
where: args.where,
Expand Down
2 changes: 2 additions & 0 deletions packages/graphql/src/schema/initCollections.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ export function initCollections({ config, graphqlResult }: InitCollectionsGraphQ
: {}),
limit: { type: GraphQLInt },
page: { type: GraphQLInt },
pagination: { type: GraphQLBoolean },
sort: { type: GraphQLString },
},
resolve: findResolver(collection),
Expand Down Expand Up @@ -351,6 +352,7 @@ export function initCollections({ config, graphqlResult }: InitCollectionsGraphQ
: {}),
limit: { type: GraphQLInt },
page: { type: GraphQLInt },
pagination: { type: GraphQLBoolean },
sort: { type: GraphQLString },
},
resolve: findVersionsResolver(collection),
Expand Down
1 change: 1 addition & 0 deletions packages/graphql/src/schema/initGlobals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ export function initGlobals({ config, graphqlResult }: InitGlobalsGraphQLArgs):
: {}),
limit: { type: GraphQLInt },
page: { type: GraphQLInt },
pagination: { type: GraphQLBoolean },
sort: { type: GraphQLString },
},
resolve: findVersions(global),
Expand Down
25 changes: 14 additions & 11 deletions packages/next/src/routes/rest/collections/find.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,19 @@ import type { CollectionRouteHandler } from '../types.js'

import { headersWithCors } from '../../../utilities/headersWithCors.js'
export const find: CollectionRouteHandler = async ({ collection, req }) => {
const { depth, draft, joins, limit, page, populate, select, sort, where } = req.query as {
depth?: string
draft?: string
joins?: JoinQuery
limit?: string
page?: string
populate?: Record<string, unknown>
select?: Record<string, unknown>
sort?: string
where?: Where
}
const { depth, draft, joins, limit, page, pagination, populate, select, sort, where } =
req.query as {
depth?: string
draft?: string
joins?: JoinQuery
limit?: string
page?: string
pagination?: string
populate?: Record<string, unknown>
select?: Record<string, unknown>
sort?: string
where?: Where
}

const result = await findOperation({
collection,
Expand All @@ -32,6 +34,7 @@ export const find: CollectionRouteHandler = async ({ collection, req }) => {
joins: sanitizeJoinParams(joins),
limit: isNumber(limit) ? Number(limit) : undefined,
page: isNumber(page) ? Number(page) : undefined,
pagination: pagination === 'false' ? false : undefined,
populate: sanitizePopulateParam(populate),
req,
select: sanitizeSelectParam(select),
Expand Down
4 changes: 3 additions & 1 deletion packages/next/src/routes/rest/collections/findVersions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ import type { CollectionRouteHandler } from '../types.js'
import { headersWithCors } from '../../../utilities/headersWithCors.js'

export const findVersions: CollectionRouteHandler = async ({ collection, req }) => {
const { depth, limit, page, populate, select, sort, where } = req.query as {
const { depth, limit, page, pagination, populate, select, sort, where } = req.query as {
depth?: string
limit?: string
page?: string
pagination?: string
populate?: Record<string, unknown>
select?: Record<string, unknown>
sort?: string
Expand All @@ -24,6 +25,7 @@ export const findVersions: CollectionRouteHandler = async ({ collection, req })
depth: isNumber(depth) ? Number(depth) : undefined,
limit: isNumber(limit) ? Number(limit) : undefined,
page: isNumber(page) ? Number(page) : undefined,
pagination: pagination === 'false' ? false : undefined,
populate: sanitizePopulateParam(populate),
req,
select: sanitizeSelectParam(select),
Expand Down
4 changes: 3 additions & 1 deletion packages/next/src/routes/rest/globals/findVersions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ import type { GlobalRouteHandler } from '../types.js'
import { headersWithCors } from '../../../utilities/headersWithCors.js'

export const findVersions: GlobalRouteHandler = async ({ globalConfig, req }) => {
const { depth, limit, page, populate, select, sort, where } = req.query as {
const { depth, limit, page, pagination, populate, select, sort, where } = req.query as {
depth?: string
limit?: string
page?: string
pagination?: string
populate?: Record<string, unknown>
select?: Record<string, unknown>
sort?: string
Expand All @@ -24,6 +25,7 @@ export const findVersions: GlobalRouteHandler = async ({ globalConfig, req }) =>
globalConfig,
limit: isNumber(limit) ? Number(limit) : undefined,
page: isNumber(page) ? Number(page) : undefined,
pagination: pagination === 'false' ? false : undefined,
populate: sanitizePopulateParam(populate),
req,
select: sanitizeSelectParam(select),
Expand Down
Loading