How to use the @webiny/commodo.createPaginationMeta function in @webiny/commodo

To help you get started, we’ve selected a few @webiny/commodo examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github webiny / webiny-js / packages / api-page-builder / src / plugins / graphql / pageResolvers / listPages.js View on Github external
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
        })
    );
};
github webiny / webiny-js / packages / api-forms / src / plugins / graphql / formResolvers / listForms.js View on Github external
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
        })
    );
};
github webiny / webiny-js / packages / api-page-builder / src / plugins / graphql / pageResolvers / listPublishedPages.js View on Github external
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);
};
github webiny / webiny-js / packages / api-forms / src / plugins / graphql / formResolvers / listPublishedForms.js View on Github external
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
        })
    );
};