-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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
[RFC] Webhook refactoring & plugins deprecation #12583
Comments
For missing webhooks, we will be adding dedicated issues. This task aims at refactoring the webhooks mechanism to move it away from plugins and make it a regular core module. Implementing webhooks as a plugin adds unnecessary complications and makes it harder to add new events.
Note - this is a significant refactoring that will affect multiple internal modules; before starting, it's worth discussing the details with the core team or providing a more detailed plan about the internal changes. |
Below is the proposition for moving logic from the WebhookPlugin into the core modules. New files structure
Todo
|
Few questions according to the structure.
|
@korycins Updated the structure to include your points. Some comments:
|
No. We have an sync webhook that is called in celery task. See
I asked about this because, currently we have webhook tests in 3 different locations. It would be great to clean it up
Does it mean that subscription types will be stored in |
I would stick to the rule that tests are next to the logic being tested, so it's a matter of organizing the logic first. Now we have two major parts:
Currently, the webhook plugin is importing the payload generator from the GraphQL layer. In the new approach the transport layer would import from GraphQL to build subscriptions. It makes sense to keep subscription definitions in the GraphQL layer; we can consider where to put the generator itself. But since we're using GraphQL to define payloads, I think we need to import parts of this logic at some point, so I'm not sure it's a bad pattern in this case. |
@maarcingebala I would also consider a different form of storing subscription types. There is no reason to store them in |
We discussed this topic with @fowczarek @korycins and @Air-t and here is the new structure we all agreed on. Files structure
Assumptions:
Example webhook definitionEach webhook will be defined in a separate file as a class. Example: from saleor.webhook.transport import AsyncWebhookTransport
class ProductCreated(AsyncWebhookTransport):
name = "Product Created"
permission = "MANAGE_PRODUCTS"
event_type = "PRODUCT_CREATED" # to replace WebhookEventAsyncType.PRODUCT_CREATED usages in codebase
subscription_type = "saleor.graphql.product.subscriptions.ProductCreated"
def legacy_payload(self):
# definition of the static legacy payload
pass Assumptions:
Other notes
|
• Identify missing webhooks
• Move webhook away from plugins
• Make it easier to add webhooks
Tasks
The text was updated successfully, but these errors were encountered: