How to use the @webiny/api.ErrorResponse 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 / commodo-graphql / src / settingsResolvers.js View on Github external
const Class = getClass(context);
    let settings = await Class.load();
    if (!settings) {
        settings = new Class();
    }

    if (!settings.data) {
        settings.data = {};
    }

    try {
        settings.data.populate(data);
        await settings.save();
        return settings;
    } catch (e) {
        return new ErrorResponse(e);
    }
};