Skip to content

feat: Add support for webhook #14

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

Merged
merged 3 commits into from
Mar 15, 2021
Merged

Conversation

vardhanapoorv
Copy link
Contributor

This PR enables support for webhook events coming from Dgraph. Check out this PR and the discuss post for more info.

Now using self.addWebHookResolvers one can add resolvers for webhook events.

async function hellowebhook({ dql, graphql, authHeader, event }) {
 ...
}

self.addWebHookResolvers({
  "User.add": hellowebhook,
})

@CLAassistant
Copy link

CLAassistant commented Mar 11, 2021

CLA assistant check
All committers have signed the CLA.

@vardhanapoorv vardhanapoorv requested a review from gja March 11, 2021 09:00
type GraphQLEventFields = {
type: string,
parents: (Record<string, any>)[] | null,
args: Record<string, any>,
authHeader?: AuthHeaderField
authHeader?: AuthHeaderField,
event?: eventPayload
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would make this a different type. Instead of GraphQLEventFields, I'd make it GraphQLChangeEventFields

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OH, this is an input thing. Could you rethink these types in such a way that GraphQLEvent doesn't have .event please?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -81,12 +91,15 @@ export function evaluateScript(source: string) {

return async function(e: GraphQLEventFields): Promise<any | undefined> {
let retPromise: ResolverResponse | undefined = undefined;
const event = {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason why this is not const? I don’t see where it is reassigned.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh my bad, fixed. thanks!

@vardhanapoorv vardhanapoorv merged commit 8bb34dd into master Mar 15, 2021
@vardhanapoorv vardhanapoorv deleted the apoorv/enable-webhook-feature branch March 18, 2021 07:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants