How to use the webiny-api/graphql/responses.ListResponse function in webiny-api

To help you get started, we’ve selected a few webiny-api 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 / webiny-api-files / src / plugins / graphql / resolvers / listFiles.js View on Github external
]
        });
    }

    if (Array.isArray(tags) && tags.length > 0) {
        $and.push({
            tags: { $in: tags.map(tag => tag.toLowerCase()) }
        });
    }

    if ($and.length) {
        findArgs.query = { $and };
    }

    const data = await entityClass.find(findArgs);
    return new ListResponse(data, data.getMeta());
};
github webiny / webiny-js / packages / webiny-api-page-builder / src / plugins / graphql / pageResolvers / listPages.js View on Github external
.getDriver()
        .aggregate(collection, [
            ...pipeline,
            { $project: { _id: -1, id: 1 } },
            { $skip: (page - 1) * perPage },
            { $limit: perPage }
        ]);

    const [totalCount] = await entityClass.getDriver().aggregate(collection, [
        ...pipeline,
        {
            $count: "totalCount"
        }
    ]);

    return new ListResponse(
        await entityClass.find({ sort, query: { id: { $in: ids.map(item => item.id) } } }),
        createPaginationMeta({
            page,
            perPage,
            totalCount: totalCount ? totalCount.totalCount : 0
        })
    );
};
github webiny / webiny-js / packages / webiny-api-page-builder / src / plugins / graphql / pageResolvers / listPublishedPages.js View on Github external
export default async (root: any, args: Object, context: Object) => {
    const Page = context.getEntity("PbPage");
    const Category = context.getEntity("PbCategory");
    const data = await listPublishedPages({ args, Page, Category });
    return new ListResponse(data, data.getMeta());
};