How to use @webiny/commodo-graphql - 10 common examples

To help you get started, we’ve selected a few @webiny/commodo-graphql 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-security / src / plugins / graphql / installResolvers / install.js View on Github external
// Update user's data
            user.firstName = data.firstName;
            user.lastName = data.lastName;
            await user.save();
        }

        try {
            await authPlugin.createUser({ data: args.data, user, permanent: true }, context);
            result.authUser = true;
        } catch {
            // Update firstName/lastName, but do not touch the existing password
            await authPlugin.updateUser({ data: omit(args.data, ["password"]), user }, context);
        }
    } catch (e) {
        if (e.code === WithFieldsError.VALIDATION_FAILED_INVALID_FIELDS) {
            const attrError = InvalidFieldsError.from(e);
            return new ErrorResponse({
                code: attrError.code || WithFieldsError.VALIDATION_FAILED_INVALID_FIELDS,
                message: attrError.message,
                data: attrError.data
            });
        }
        return new ErrorResponse({
            code: e.code,
            message: e.message,
            data: e.data
        });
    }

    return new Response(result);
};
github webiny / webiny-js / packages / api-page-builder / src / plugins / graphql / Page.js View on Github external
publishRevision: (_: any, args: Object, ctx: Object, info: Object) => {
                args.data = { published: true };

                return resolveUpdate(pageFetcher)(_, args, ctx, info);
            },
            // Delete a revision
github webiny / webiny-js / packages / api-page-builder / src / plugins / graphql / Page.js View on Github external
// Creates a revision from the given revision
            createRevisionFrom: createRevisionFrom,
            // Updates revision
            updateRevision: resolveUpdate(pageFetcher),
            // Publish revision (must be given an exact revision ID to publish)
            publishRevision: (_: any, args: Object, ctx: Object, info: Object) => {
                args.data = { published: true };

                return resolveUpdate(pageFetcher)(_, args, ctx, info);
            },
            // Delete a revision
            deleteRevision: resolveDelete(pageFetcher),
            // Creates a new element
            createElement: resolveCreate(elementFetcher),
            // Updates an element
            updateElement: resolveUpdate(elementFetcher),
            // Deletes an element
            deleteElement: resolveDelete(elementFetcher)
        },
        PbPageSettings: {
            _empty: () => ""
        }
    }
};
github webiny / webiny-js / packages / api-page-builder / src / plugins / graphql / Page.js View on Github external
return await resolver.resolve(root, args, context, info);
            },
            oembedData: oembed
        },
        PbMutation: {
            // Creates a new page
            createPage: resolveCreate(pageFetcher),
            // Deletes the entire page
            deletePage: resolveDelete(pageFetcher),
            // Sets given page as home page.
            setHomePage,
            // Creates a revision from the given revision
            createRevisionFrom: createRevisionFrom,
            // Updates revision
            updateRevision: resolveUpdate(pageFetcher),
            // Publish revision (must be given an exact revision ID to publish)
            publishRevision: (_: any, args: Object, ctx: Object, info: Object) => {
                args.data = { published: true };

                return resolveUpdate(pageFetcher)(_, args, ctx, info);
            },
            // Delete a revision
            deleteRevision: resolveDelete(pageFetcher),
            // Creates a new element
            createElement: resolveCreate(elementFetcher),
            // Updates an element
            updateElement: resolveUpdate(elementFetcher),
            // Deletes an element
            deleteElement: resolveDelete(elementFetcher)
        },
        PbPageSettings: {
github webiny / webiny-js / packages / api-forms / src / plugins / graphql / form.js View on Github external
resolvers: {
        FormsQuery: {
            getForm: resolveGet(getForm),
            listForms,
            listPublishedForms,
            getPublishedForm
        },
        FormsMutation: {
            // Creates a new form
            createForm: resolveCreate(getForm),
            // Deletes the entire form
            deleteForm: resolveDelete(getForm),
            // Creates a revision from the given revision
            createRevisionFrom: createRevisionFrom,
            // Updates revision
            updateRevision: resolveUpdate(getForm),
            // Publish revision (must be given an exact revision ID to publish)
            publishRevision: (_: any, args: Object, ctx: Object) => {
                args.data = { published: true };

                return resolveUpdate(getForm)(_, args, ctx);
            },
            unpublishRevision: (_: any, args: Object, ctx: Object) => {
                args.data = { published: false };

                return resolveUpdate(getForm)(_, args, ctx);
            },
            // Delete a revision
            deleteRevision: resolveDelete(getForm),
            saveFormView
        }
    }
github webiny / webiny-js / packages / api-forms / src / plugins / graphql / form.js View on Github external
# Logs a view of a form
            saveFormView(id: ID!): SaveFormViewResponse
        }
    `,
    resolvers: {
        FormsQuery: {
            getForm: resolveGet(getForm),
            listForms,
            listPublishedForms,
            getPublishedForm
        },
        FormsMutation: {
            // Creates a new form
            createForm: resolveCreate(getForm),
            // Deletes the entire form
            deleteForm: resolveDelete(getForm),
            // Creates a revision from the given revision
            createRevisionFrom: createRevisionFrom,
            // Updates revision
            updateRevision: resolveUpdate(getForm),
            // Publish revision (must be given an exact revision ID to publish)
            publishRevision: (_: any, args: Object, ctx: Object) => {
                args.data = { published: true };

                return resolveUpdate(getForm)(_, args, ctx);
            },
            unpublishRevision: (_: any, args: Object, ctx: Object) => {
                args.data = { published: false };

                return resolveUpdate(getForm)(_, args, ctx);
            },
            // Delete a revision
github webiny / webiny-js / packages / api-page-builder / src / plugins / graphql / Page.js View on Github external
getHomePage,
            getNotFoundPage,
            getErrorPage,
            listElements: resolveList(elementFetcher),
            searchTags: async (root: any, args: Object, context: Object, info: Object) => {
                const resolver = context.plugins.byName("pb-resolver-search-tags");

                return await resolver.resolve(root, args, context, info);
            },
            oembedData: oembed
        },
        PbMutation: {
            // Creates a new page
            createPage: resolveCreate(pageFetcher),
            // Deletes the entire page
            deletePage: resolveDelete(pageFetcher),
            // Sets given page as home page.
            setHomePage,
            // Creates a revision from the given revision
            createRevisionFrom: createRevisionFrom,
            // Updates revision
            updateRevision: resolveUpdate(pageFetcher),
            // Publish revision (must be given an exact revision ID to publish)
            publishRevision: (_: any, args: Object, ctx: Object, info: Object) => {
                args.data = { published: true };

                return resolveUpdate(pageFetcher)(_, args, ctx, info);
            },
            // Delete a revision
            deleteRevision: resolveDelete(pageFetcher),
            // Creates a new element
            createElement: resolveCreate(elementFetcher),
github webiny / webiny-js / packages / api-forms / src / plugins / graphql / form.js View on Github external
createRevisionFrom: createRevisionFrom,
            // Updates revision
            updateRevision: resolveUpdate(getForm),
            // Publish revision (must be given an exact revision ID to publish)
            publishRevision: (_: any, args: Object, ctx: Object) => {
                args.data = { published: true };

                return resolveUpdate(getForm)(_, args, ctx);
            },
            unpublishRevision: (_: any, args: Object, ctx: Object) => {
                args.data = { published: false };

                return resolveUpdate(getForm)(_, args, ctx);
            },
            // Delete a revision
            deleteRevision: resolveDelete(getForm),
            saveFormView
        }
    }
};
github webiny / webiny-js / packages / api-page-builder / src / plugins / graphql / Page.js View on Github external
// Deletes the entire page
            deletePage: resolveDelete(pageFetcher),
            // Sets given page as home page.
            setHomePage,
            // Creates a revision from the given revision
            createRevisionFrom: createRevisionFrom,
            // Updates revision
            updateRevision: resolveUpdate(pageFetcher),
            // Publish revision (must be given an exact revision ID to publish)
            publishRevision: (_: any, args: Object, ctx: Object, info: Object) => {
                args.data = { published: true };

                return resolveUpdate(pageFetcher)(_, args, ctx, info);
            },
            // Delete a revision
            deleteRevision: resolveDelete(pageFetcher),
            // Creates a new element
            createElement: resolveCreate(elementFetcher),
            // Updates an element
            updateElement: resolveUpdate(elementFetcher),
            // Deletes an element
            deleteElement: resolveDelete(elementFetcher)
        },
        PbPageSettings: {
            _empty: () => ""
        }
    }
};
github webiny / webiny-js / packages / api-page-builder / src / plugins / graphql / Page.js View on Github external
resolvers: {
        PbPage: {
            createdBy(page) {
                return { __typename: "SecurityUser", id: page.createdBy };
            },
            updatedBy(page) {
                return { __typename: "SecurityUser", id: page.updatedBy };
            }
        },
        PbElement: {
            preview({ preview }) {
                return preview ? { __typename: "File", id: preview } : null;
            }
        },
        PbQuery: {
            getPage: resolveGet(pageFetcher),
            listPages: listPages,
            listPublishedPages,
            getPublishedPage,
            getHomePage,
            getNotFoundPage,
            getErrorPage,
            listElements: resolveList(elementFetcher),
            searchTags: async (root: any, args: Object, context: Object, info: Object) => {
                const resolver = context.plugins.byName("pb-resolver-search-tags");

                return await resolver.resolve(root, args, context, info);
            },
            oembedData: oembed
        },
        PbMutation: {
            // Creates a new page