Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export default async (root: any, args: Object, context: Object) => {
const plugin = context.plugins.byName("pb-resolver-list-pages");
if (!plugin) {
throw Error(`Resolver plugin "pb-resolver-list-pages" is not configured!`);
}
const { pages, totalCount } = await plugin.resolve({ args, context });
return new ListResponse(
pages,
createPaginationMeta({
page: args.page,
perPage: args.perPage,
totalCount: totalCount ? totalCount : 0
})
);
};
if (!plugin) {
throw Error(`Resolver plugin "forms-resolver-list-forms" is not configured!`);
}
const { forms, totalCount } = await plugin.resolve({ root, args, context });
if (!Array.isArray(forms) || !Number.isInteger(totalCount)) {
throw Error(
`Resolver plugin "forms-resolver-list-forms" must return { forms: [Form], totalCount: Int }!`
);
}
return new ListResponse(
forms,
createPaginationMeta({
page: args.page,
perPage: args.perPage,
totalCount: totalCount ? totalCount : 0
})
);
};
export const listPublishedPages = async ({ args, context }: Object) => {
const plugin = context.plugins.byName("pb-resolver-list-published-pages");
if (!plugin) {
throw Error(`Resolver plugin "pb-resolver-list-published-pages" is not configured!`);
}
const { pages, totalCount } = await plugin.resolve({ args, context });
const meta = createPaginationMeta({
totalCount,
page: args.page,
perPage: args.perPage
});
return new Collection(pages).setMeta(meta);
};
export default async (root: any, args: Object, context: Object) => {
const plugin = getListPublishedFormsResolver(context);
const { forms, totalCount } = await plugin.resolve({ root, args, context });
if (!Array.isArray(forms) || !Number.isInteger(totalCount)) {
throw Error(
`Resolver plugin "forms-resolver-list-published-forms" must return { forms: [Form], totalCount: Int }!`
);
}
return new ListResponse(
forms,
createPaginationMeta({
page: args.page,
perPage: args.perPage,
totalCount: totalCount ? totalCount : 0
})
);
};