fix: #2937, depth not being respected in graphql rich text fields

This commit is contained in:
James
2023-06-29 20:08:39 -04:00
parent 0112f4c4ab
commit f84b4323e2
7 changed files with 33 additions and 9 deletions

View File

@@ -11,6 +11,7 @@ function loginResolver(collection: Collection) {
},
req: context.req,
res: context.res,
depth: 0,
};
const result = login(options);

View File

@@ -6,6 +6,7 @@ function meResolver(collection: Collection): any {
const options = {
collection,
req: context.req,
depth: 0,
};
return me(options);
}

View File

@@ -18,6 +18,7 @@ function refreshResolver(collection: Collection) {
token,
req: context.req,
res: context.res,
depth: 0,
};
const result = await refresh(options);

View File

@@ -13,6 +13,7 @@ function resetPasswordResolver(collection: Collection) {
req: context.req,
res: context.res,
api: 'GraphQL',
depth: 0,
};
const result = await resetPassword(options);

View File

@@ -23,6 +23,7 @@ export type Arguments = {
req: PayloadRequest
overrideAccess?: boolean
res?: Response
depth?: number
}
async function resetPassword(args: Arguments): Promise<Result> {
@@ -45,6 +46,7 @@ async function resetPassword(args: Arguments): Promise<Result> {
},
overrideAccess,
data,
depth,
} = args;
// /////////////////////////////////////
@@ -119,7 +121,7 @@ async function resetPassword(args: Arguments): Promise<Result> {
args.res.cookie(`${config.cookiePrefix}-token`, token, cookieOptions);
}
const fullUser = await payload.findByID({ collection: collectionConfig.slug, id: user.id, overrideAccess });
const fullUser = await payload.findByID({ collection: collectionConfig.slug, id: user.id, overrideAccess, depth });
return { token, user: fullUser };
}

View File

@@ -33,13 +33,8 @@ export async function afterRead<T = any>(args: Args): Promise<T> {
const fieldPromises = [];
const populationPromises = [];
let depth = 0;
if (req.payloadAPI === 'REST' || req.payloadAPI === 'local') {
depth = (incomingDepth || incomingDepth === 0) ? parseInt(String(incomingDepth), 10) : req.payload.config.defaultDepth;
if (depth > req.payload.config.maxDepth) depth = req.payload.config.maxDepth;
}
let depth = (incomingDepth || incomingDepth === 0) ? parseInt(String(incomingDepth), 10) : req.payload.config.defaultDepth;
if (depth > req.payload.config.maxDepth) depth = req.payload.config.maxDepth;
const currentDepth = incomingCurrentDepth || 1;