-
Notifications
You must be signed in to change notification settings - Fork 5
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
feat: add app event filter type to functions [EXT-5089] #566
feat: add app event filter type to functions [EXT-5089] #566
Conversation
src/requests/typings/function.ts
Outdated
entityProps: T | ||
entityAction: string // 'create' | 'publish' etc etc. | ||
} | ||
// TODO: use generic to DRY this up? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we get rid of this comment now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it looks like it! but also we need a TODO to make this exhaustive of all of the other entity types/actions that an app event subscription can receive (e.g. all of these that apply to AppEvents https://www.contentful.com/developers/docs/webhooks/content-events/)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed this comment // TODO: use generic to DRY this up?
and updated a comment to reflect that we need to update the app event subscription entities and topics/actions // TODO: add all of the other app event subscription entities and topics/actions
src/requests/typings/function.ts
Outdated
|
||
export type AppEventFilterResponse = { | ||
result: boolean | ||
errors?: readonly Record<string, any>[] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the intent of this property?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we were following suit with delivery function response shape in case there were errors to bubble up, but we're not 100% sure if we need this yet to be honest. hence this being a draft still as we connect the full e2e dots together 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think i was imaging something like:
- function expects entry Foo to have "slug" field, but it doesn't
- so it returns
false
as theresult
value causing the app event to be filtered and not sent to the final destination & includes error details something like:"missingExpectedField": "No "slug" field to validate on entry. Field not present in ContentType "blogPost"
or whatever which could be useful elsewhere like the logs? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The example makes sense 👍🏻 The question is who takes care of logging that, is that the filter function itself or do you want to put that concern on the system invoking the function?
For context: The errors
prop in the graphql.query
response comes from the fact that we simply follow the GQL spec and specifically this part:
If a field error is raised, execution attempts to continue and a partial result is produced (see Handling Field Errors). The data entry in the response must be present. The errors entry should include all raised field errors.
Co-authored-by: Tyler Collins <104802020+t-col@users.noreply.github.com>
Co-authored-by: Tyler Collins <104802020+t-col@users.noreply.github.com>
# [3.3.0](v3.2.1...v3.3.0) (2024-03-27) ### Features * add app event filter type to functions [EXT-5089] ([#566](#566)) ([f8ea2cb](f8ea2cb))
🎉 This PR is included in version 3.3.0 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
This PR adds the new appevent.filter event type to the function handler for app functions. This then can be imported into our example apps that utilize functions.