Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support to define before/after graphql-sequelize hooks #60

Merged

Conversation

jjcollinge
Copy link
Contributor

@jjcollinge jjcollinge commented Dec 1, 2021

Add support to define before/after graphql-sequelize before and after hooks on a model.
With this change, if you have added a before or after find hook then it will be invoked.

This allows you to define the hooks on the model graphql object like so:

 model.graphql = {
    find: {
        before: (findOptions, args, context) => {
            // modify findOptions
            console.log(findOptions);
        },
        after: (result, args, context) => {
           // do something with result
            console.log(result);
            return result;
        }
    }
}

The definition of graphql-sequelize hook options can be found at https://github.com/mickhansen/graphql-sequelize/tree/a8bccd7f09f8a89aca689104800083f4e17e8ab4#options

Please see #59 for more details.

@jjcollinge jjcollinge marked this pull request as ready for review December 1, 2021 16:24
@jjcollinge jjcollinge changed the title [WIP] Add support to define before/after graphql-sequelize hooks Add support to define before/after graphql-sequelize hooks Dec 1, 2021
@alirizwan
Copy link
Collaborator

Thank you, I will test and merge.

@Nepomuceno
Copy link

👍

@alirizwan alirizwan merged commit 31ab7e7 into almost-full-stack:develop Feb 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants