fix: make list webhooks params optional
This commit is contained in:
@@ -12,7 +12,7 @@ import (
|
||||
)
|
||||
|
||||
// WebhookLogsResolver resolver for getting the list of webhook_logs based on pagination & webhook identifier
|
||||
func WebhookLogsResolver(ctx context.Context, params model.ListWebhookLogRequest) (*model.WebhookLogs, error) {
|
||||
func WebhookLogsResolver(ctx context.Context, params *model.ListWebhookLogRequest) (*model.WebhookLogs, error) {
|
||||
gc, err := utils.GinContextFromContext(ctx)
|
||||
if err != nil {
|
||||
log.Debug("Failed to get GinContext: ", err)
|
||||
@@ -24,11 +24,20 @@ func WebhookLogsResolver(ctx context.Context, params model.ListWebhookLogRequest
|
||||
return nil, fmt.Errorf("unauthorized")
|
||||
}
|
||||
|
||||
pagination := utils.GetPagination(&model.PaginatedInput{
|
||||
Pagination: params.Pagination,
|
||||
})
|
||||
var pagination model.Pagination
|
||||
var webhookID string
|
||||
|
||||
webhookLogs, err := db.Provider.ListWebhookLogs(ctx, pagination, utils.StringValue(params.WebhookID))
|
||||
if params != nil {
|
||||
pagination = utils.GetPagination(&model.PaginatedInput{
|
||||
Pagination: params.Pagination,
|
||||
})
|
||||
webhookID = utils.StringValue(params.WebhookID)
|
||||
} else {
|
||||
pagination = utils.GetPagination(nil)
|
||||
webhookID = ""
|
||||
}
|
||||
|
||||
webhookLogs, err := db.Provider.ListWebhookLogs(ctx, pagination, webhookID)
|
||||
if err != nil {
|
||||
log.Debug("failed to get webhook logs: ", err)
|
||||
return nil, err
|
||||
|
Reference in New Issue
Block a user