diff --git a/server/db/providers/arangodb/webhook.go b/server/db/providers/arangodb/webhook.go new file mode 100644 index 0000000..3dd7c9e --- /dev/null +++ b/server/db/providers/arangodb/webhook.go @@ -0,0 +1,36 @@ +package arangodb + +import ( + "github.com/authorizerdev/authorizer/server/db/models" + "github.com/authorizerdev/authorizer/server/graph/model" +) + +// AddWebhook to add webhook +func (p *provider) AddWebhook(webhook models.Webhook) (models.Webhook, error) { + return webhook, nil +} + +// UpdateWebhook to update webhook +func (p *provider) UpdateWebhook(webhook models.Webhook) (models.Webhook, error) { + return webhook, nil +} + +// ListWebhooks to list webhook +func (p *provider) ListWebhook(pagination model.Pagination) (*model.Webhooks, error) { + return nil, nil +} + +// GetWebhookByID to get webhook by id +func (p *provider) GetWebhookByID(webhookID string) (models.Webhook, error) { + return models.Webhook{}, nil +} + +// GetWebhookByEvent to get webhook by event_name +func (p *provider) GetWebhookByEvent(eventName string) (models.Webhook, error) { + return models.Webhook{}, nil +} + +// DeleteWebhook to delete webhook +func (p *provider) DeleteWebhook(webhookID string) error { + return nil +} diff --git a/server/db/providers/arangodb/webhook_log.go b/server/db/providers/arangodb/webhook_log.go new file mode 100644 index 0000000..aa41366 --- /dev/null +++ b/server/db/providers/arangodb/webhook_log.go @@ -0,0 +1,16 @@ +package arangodb + +import ( + "github.com/authorizerdev/authorizer/server/db/models" + "github.com/authorizerdev/authorizer/server/graph/model" +) + +// AddWebhookLog to add webhook log +func (p *provider) AddWebhookLog(webhookLog models.WebhookLog) (models.WebhookLog, error) { + return webhookLog, nil +} + +// ListWebhookLogs to list webhook logs +func (p *provider) ListWebhookLogs(req model.ListWebhookLogRequest) (*model.WebhookLogs, error) { + return nil, nil +} diff --git a/server/db/providers/cassandradb/webhook.go b/server/db/providers/cassandradb/webhook.go new file mode 100644 index 0000000..79ea9a7 --- /dev/null +++ b/server/db/providers/cassandradb/webhook.go @@ -0,0 +1,36 @@ +package cassandradb + +import ( + "github.com/authorizerdev/authorizer/server/db/models" + "github.com/authorizerdev/authorizer/server/graph/model" +) + +// AddWebhook to add webhook +func (p *provider) AddWebhook(webhook models.Webhook) (models.Webhook, error) { + return webhook, nil +} + +// UpdateWebhook to update webhook +func (p *provider) UpdateWebhook(webhook models.Webhook) (models.Webhook, error) { + return webhook, nil +} + +// ListWebhooks to list webhook +func (p *provider) ListWebhook(pagination model.Pagination) (*model.Webhooks, error) { + return nil, nil +} + +// GetWebhookByID to get webhook by id +func (p *provider) GetWebhookByID(webhookID string) (models.Webhook, error) { + return models.Webhook{}, nil +} + +// GetWebhookByEvent to get webhook by event_name +func (p *provider) GetWebhookByEvent(eventName string) (models.Webhook, error) { + return models.Webhook{}, nil +} + +// DeleteWebhook to delete webhook +func (p *provider) DeleteWebhook(webhookID string) error { + return nil +} diff --git a/server/db/providers/cassandradb/webhook_log.go b/server/db/providers/cassandradb/webhook_log.go new file mode 100644 index 0000000..4ea41e2 --- /dev/null +++ b/server/db/providers/cassandradb/webhook_log.go @@ -0,0 +1,16 @@ +package cassandradb + +import ( + "github.com/authorizerdev/authorizer/server/db/models" + "github.com/authorizerdev/authorizer/server/graph/model" +) + +// AddWebhookLog to add webhook log +func (p *provider) AddWebhookLog(webhookLog models.WebhookLog) (models.WebhookLog, error) { + return webhookLog, nil +} + +// ListWebhookLogs to list webhook logs +func (p *provider) ListWebhookLogs(req model.ListWebhookLogRequest) (*model.WebhookLogs, error) { + return nil, nil +} diff --git a/server/db/providers/mongodb/webhook.go b/server/db/providers/mongodb/webhook.go new file mode 100644 index 0000000..5669a12 --- /dev/null +++ b/server/db/providers/mongodb/webhook.go @@ -0,0 +1,36 @@ +package mongodb + +import ( + "github.com/authorizerdev/authorizer/server/db/models" + "github.com/authorizerdev/authorizer/server/graph/model" +) + +// AddWebhook to add webhook +func (p *provider) AddWebhook(webhook models.Webhook) (models.Webhook, error) { + return webhook, nil +} + +// UpdateWebhook to update webhook +func (p *provider) UpdateWebhook(webhook models.Webhook) (models.Webhook, error) { + return webhook, nil +} + +// ListWebhooks to list webhook +func (p *provider) ListWebhook(pagination model.Pagination) (*model.Webhooks, error) { + return nil, nil +} + +// GetWebhookByID to get webhook by id +func (p *provider) GetWebhookByID(webhookID string) (models.Webhook, error) { + return models.Webhook{}, nil +} + +// GetWebhookByEvent to get webhook by event_name +func (p *provider) GetWebhookByEvent(eventName string) (models.Webhook, error) { + return models.Webhook{}, nil +} + +// DeleteWebhook to delete webhook +func (p *provider) DeleteWebhook(webhookID string) error { + return nil +} diff --git a/server/db/providers/mongodb/webhook_log.go b/server/db/providers/mongodb/webhook_log.go new file mode 100644 index 0000000..c497a4c --- /dev/null +++ b/server/db/providers/mongodb/webhook_log.go @@ -0,0 +1,16 @@ +package mongodb + +import ( + "github.com/authorizerdev/authorizer/server/db/models" + "github.com/authorizerdev/authorizer/server/graph/model" +) + +// AddWebhookLog to add webhook log +func (p *provider) AddWebhookLog(webhookLog models.WebhookLog) (models.WebhookLog, error) { + return webhookLog, nil +} + +// ListWebhookLogs to list webhook logs +func (p *provider) ListWebhookLogs(req model.ListWebhookLogRequest) (*model.WebhookLogs, error) { + return nil, nil +} diff --git a/server/db/providers/provider_template/webhook.go b/server/db/providers/provider_template/webhook.go new file mode 100644 index 0000000..1717ca6 --- /dev/null +++ b/server/db/providers/provider_template/webhook.go @@ -0,0 +1,36 @@ +package provider_template + +import ( + "github.com/authorizerdev/authorizer/server/db/models" + "github.com/authorizerdev/authorizer/server/graph/model" +) + +// AddWebhook to add webhook +func (p *provider) AddWebhook(webhook models.Webhook) (models.Webhook, error) { + return webhook, nil +} + +// UpdateWebhook to update webhook +func (p *provider) UpdateWebhook(webhook models.Webhook) (models.Webhook, error) { + return webhook, nil +} + +// ListWebhooks to list webhook +func (p *provider) ListWebhook(pagination model.Pagination) (*model.Webhooks, error) { + return nil, nil +} + +// GetWebhookByID to get webhook by id +func (p *provider) GetWebhookByID(webhookID string) (models.Webhook, error) { + return models.Webhook{}, nil +} + +// GetWebhookByEvent to get webhook by event_name +func (p *provider) GetWebhookByEvent(eventName string) (models.Webhook, error) { + return models.Webhook{}, nil +} + +// DeleteWebhook to delete webhook +func (p *provider) DeleteWebhook(webhookID string) error { + return nil +} diff --git a/server/db/providers/provider_template/webhook_log.go b/server/db/providers/provider_template/webhook_log.go new file mode 100644 index 0000000..860a8c0 --- /dev/null +++ b/server/db/providers/provider_template/webhook_log.go @@ -0,0 +1,16 @@ +package provider_template + +import ( + "github.com/authorizerdev/authorizer/server/db/models" + "github.com/authorizerdev/authorizer/server/graph/model" +) + +// AddWebhookLog to add webhook log +func (p *provider) AddWebhookLog(webhookLog models.WebhookLog) (models.WebhookLog, error) { + return webhookLog, nil +} + +// ListWebhookLogs to list webhook logs +func (p *provider) ListWebhookLogs(req model.ListWebhookLogRequest) (*model.WebhookLogs, error) { + return nil, nil +} diff --git a/server/db/providers/providers.go b/server/db/providers/providers.go index aa69c66..cb7caea 100644 --- a/server/db/providers/providers.go +++ b/server/db/providers/providers.go @@ -41,4 +41,22 @@ type Provider interface { UpdateEnv(env models.Env) (models.Env, error) // GetEnv to get environment information from database GetEnv() (models.Env, error) + + // AddWebhook to add webhook + AddWebhook(webhook models.Webhook) (models.Webhook, error) + // UpdateWebhook to update webhook + UpdateWebhook(webhook models.Webhook) (models.Webhook, error) + // ListWebhooks to list webhook + ListWebhook(pagination model.Pagination) (*model.Webhooks, error) + // GetWebhookByID to get webhook by id + GetWebhookByID(webhookID string) (models.Webhook, error) + // GetWebhookByEvent to get webhook by event_name + GetWebhookByEvent(eventName string) (models.Webhook, error) + // DeleteWebhook to delete webhook + DeleteWebhook(webhookID string) error + + // AddWebhookLog to add webhook log + AddWebhookLog(webhookLog models.WebhookLog) (models.WebhookLog, error) + // ListWebhookLogs to list webhook logs + ListWebhookLogs(req model.ListWebhookLogRequest) (*model.WebhookLogs, error) } diff --git a/server/db/providers/sql/webhook.go b/server/db/providers/sql/webhook.go new file mode 100644 index 0000000..58abee6 --- /dev/null +++ b/server/db/providers/sql/webhook.go @@ -0,0 +1,36 @@ +package sql + +import ( + "github.com/authorizerdev/authorizer/server/db/models" + "github.com/authorizerdev/authorizer/server/graph/model" +) + +// AddWebhook to add webhook +func (p *provider) AddWebhook(webhook models.Webhook) (models.Webhook, error) { + return webhook, nil +} + +// UpdateWebhook to update webhook +func (p *provider) UpdateWebhook(webhook models.Webhook) (models.Webhook, error) { + return webhook, nil +} + +// ListWebhooks to list webhook +func (p *provider) ListWebhook(pagination model.Pagination) (*model.Webhooks, error) { + return nil, nil +} + +// GetWebhookByID to get webhook by id +func (p *provider) GetWebhookByID(webhookID string) (models.Webhook, error) { + return models.Webhook{}, nil +} + +// GetWebhookByEvent to get webhook by event_name +func (p *provider) GetWebhookByEvent(eventName string) (models.Webhook, error) { + return models.Webhook{}, nil +} + +// DeleteWebhook to delete webhook +func (p *provider) DeleteWebhook(webhookID string) error { + return nil +} diff --git a/server/db/providers/sql/webhook_log.go b/server/db/providers/sql/webhook_log.go new file mode 100644 index 0000000..6f19e2a --- /dev/null +++ b/server/db/providers/sql/webhook_log.go @@ -0,0 +1,16 @@ +package sql + +import ( + "github.com/authorizerdev/authorizer/server/db/models" + "github.com/authorizerdev/authorizer/server/graph/model" +) + +// AddWebhookLog to add webhook log +func (p *provider) AddWebhookLog(webhookLog models.WebhookLog) (models.WebhookLog, error) { + return webhookLog, nil +} + +// ListWebhookLogs to list webhook logs +func (p *provider) ListWebhookLogs(req model.ListWebhookLogRequest) (*model.WebhookLogs, error) { + return nil, nil +} diff --git a/server/graph/generated/generated.go b/server/graph/generated/generated.go index 13421fd..da9aaa0 100644 --- a/server/graph/generated/generated.go +++ b/server/graph/generated/generated.go @@ -168,6 +168,8 @@ type ComplexityRoot struct { Users func(childComplexity int, params *model.PaginatedInput) int ValidateJwtToken func(childComplexity int, params model.ValidateJWTTokenInput) int VerificationRequests func(childComplexity int, params *model.PaginatedInput) int + WebhookLogs func(childComplexity int, params *model.ListWebhookLogRequest) int + Webhooks func(childComplexity int, params *model.PaginatedInput) int } Response struct { @@ -220,6 +222,35 @@ type ComplexityRoot struct { Pagination func(childComplexity int) int VerificationRequests func(childComplexity int) int } + + Webhook struct { + CreatedAt func(childComplexity int) int + Enabled func(childComplexity int) int + Endpoint func(childComplexity int) int + EventName func(childComplexity int) int + ID func(childComplexity int) int + UpdatedAt func(childComplexity int) int + } + + WebhookLog struct { + CreatedAt func(childComplexity int) int + HTTPStatus func(childComplexity int) int + ID func(childComplexity int) int + Request func(childComplexity int) int + Response func(childComplexity int) int + UpdatedAt func(childComplexity int) int + WebhookID func(childComplexity int) int + } + + WebhookLogs struct { + Pagination func(childComplexity int) int + WebhookLogs func(childComplexity int) int + } + + Webhooks struct { + Pagination func(childComplexity int) int + Webhooks func(childComplexity int) int + } } type MutationResolver interface { @@ -253,6 +284,8 @@ type QueryResolver interface { VerificationRequests(ctx context.Context, params *model.PaginatedInput) (*model.VerificationRequests, error) AdminSession(ctx context.Context) (*model.Response, error) Env(ctx context.Context) (*model.Env, error) + Webhooks(ctx context.Context, params *model.PaginatedInput) (*model.Webhooks, error) + WebhookLogs(ctx context.Context, params *model.ListWebhookLogRequest) (*model.WebhookLogs, error) } type executableSchema struct { @@ -1101,6 +1134,30 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Query.VerificationRequests(childComplexity, args["params"].(*model.PaginatedInput)), true + case "Query._webhook_logs": + if e.complexity.Query.WebhookLogs == nil { + break + } + + args, err := ec.field_Query__webhook_logs_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.WebhookLogs(childComplexity, args["params"].(*model.ListWebhookLogRequest)), true + + case "Query._webhooks": + if e.complexity.Query.Webhooks == nil { + break + } + + args, err := ec.field_Query__webhooks_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.Webhooks(childComplexity, args["params"].(*model.PaginatedInput)), true + case "Response.message": if e.complexity.Response.Message == nil { break @@ -1332,6 +1389,125 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.VerificationRequests.VerificationRequests(childComplexity), true + case "Webhook.created_at": + if e.complexity.Webhook.CreatedAt == nil { + break + } + + return e.complexity.Webhook.CreatedAt(childComplexity), true + + case "Webhook.enabled": + if e.complexity.Webhook.Enabled == nil { + break + } + + return e.complexity.Webhook.Enabled(childComplexity), true + + case "Webhook.endpoint": + if e.complexity.Webhook.Endpoint == nil { + break + } + + return e.complexity.Webhook.Endpoint(childComplexity), true + + case "Webhook.event_name": + if e.complexity.Webhook.EventName == nil { + break + } + + return e.complexity.Webhook.EventName(childComplexity), true + + case "Webhook.id": + if e.complexity.Webhook.ID == nil { + break + } + + return e.complexity.Webhook.ID(childComplexity), true + + case "Webhook.updated_at": + if e.complexity.Webhook.UpdatedAt == nil { + break + } + + return e.complexity.Webhook.UpdatedAt(childComplexity), true + + case "WebhookLog.created_at": + if e.complexity.WebhookLog.CreatedAt == nil { + break + } + + return e.complexity.WebhookLog.CreatedAt(childComplexity), true + + case "WebhookLog.http_status": + if e.complexity.WebhookLog.HTTPStatus == nil { + break + } + + return e.complexity.WebhookLog.HTTPStatus(childComplexity), true + + case "WebhookLog.id": + if e.complexity.WebhookLog.ID == nil { + break + } + + return e.complexity.WebhookLog.ID(childComplexity), true + + case "WebhookLog.request": + if e.complexity.WebhookLog.Request == nil { + break + } + + return e.complexity.WebhookLog.Request(childComplexity), true + + case "WebhookLog.response": + if e.complexity.WebhookLog.Response == nil { + break + } + + return e.complexity.WebhookLog.Response(childComplexity), true + + case "WebhookLog.updated_at": + if e.complexity.WebhookLog.UpdatedAt == nil { + break + } + + return e.complexity.WebhookLog.UpdatedAt(childComplexity), true + + case "WebhookLog.webhook_id": + if e.complexity.WebhookLog.WebhookID == nil { + break + } + + return e.complexity.WebhookLog.WebhookID(childComplexity), true + + case "WebhookLogs.pagination": + if e.complexity.WebhookLogs.Pagination == nil { + break + } + + return e.complexity.WebhookLogs.Pagination(childComplexity), true + + case "WebhookLogs.webhook_logs": + if e.complexity.WebhookLogs.WebhookLogs == nil { + break + } + + return e.complexity.WebhookLogs.WebhookLogs(childComplexity), true + + case "Webhooks.pagination": + if e.complexity.Webhooks.Pagination == nil { + break + } + + return e.complexity.Webhooks.Pagination(childComplexity), true + + case "Webhooks.webhooks": + if e.complexity.Webhooks.Webhooks == nil { + break + } + + return e.complexity.Webhooks.Webhooks(childComplexity), true + } return 0, false } @@ -1400,6 +1576,7 @@ var sources = []*ast.Source{ # # https://gqlgen.com/getting-started/ scalar Int64 +scalar Int32 scalar Map scalar Any @@ -1722,6 +1899,40 @@ input GenerateJWTKeysInput { type: String! } +type Webhook { + id: ID! + event_name: String + endpoint: String + enabled: Boolean + created_at: Int64 + updated_at: Int64 +} + +type Webhooks { + pagination: Pagination! + webhooks: [Webhook!]! +} + +type WebhookLog { + id: ID! + http_status: Int32 + response: String + request: String + webhook_id: ID + created_at: Int64 + updated_at: Int64 +} + +input ListWebhookLogRequest { + pagination: PaginatedInput! + webhook_id: String +} + +type WebhookLogs { + pagination: Pagination! + webhook_logs: [WebhookLog!]! +} + type Mutation { signup(params: SignUpInput!): AuthResponse! login(params: LoginInput!): AuthResponse! @@ -1756,6 +1967,8 @@ type Query { _verification_requests(params: PaginatedInput): VerificationRequests! _admin_session: Response! _env: Env! + _webhooks(params: PaginatedInput): Webhooks! + _webhook_logs(params: ListWebhookLogRequest): WebhookLogs! } `, BuiltIn: false}, } @@ -2080,6 +2293,36 @@ func (ec *executionContext) field_Query__verification_requests_args(ctx context. return args, nil } +func (ec *executionContext) field_Query__webhook_logs_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 *model.ListWebhookLogRequest + if tmp, ok := rawArgs["params"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("params")) + arg0, err = ec.unmarshalOListWebhookLogRequest2ᚖgithubᚗcomᚋauthorizerdevᚋauthorizerᚋserverᚋgraphᚋmodelᚐListWebhookLogRequest(ctx, tmp) + if err != nil { + return nil, err + } + } + args["params"] = arg0 + return args, nil +} + +func (ec *executionContext) field_Query__webhooks_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 *model.PaginatedInput + if tmp, ok := rawArgs["params"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("params")) + arg0, err = ec.unmarshalOPaginatedInput2ᚖgithubᚗcomᚋauthorizerdevᚋauthorizerᚋserverᚋgraphᚋmodelᚐPaginatedInput(ctx, tmp) + if err != nil { + return nil, err + } + } + args["params"] = arg0 + return args, nil +} + func (ec *executionContext) field_Query_session_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} @@ -5766,6 +6009,90 @@ func (ec *executionContext) _Query__env(ctx context.Context, field graphql.Colle return ec.marshalNEnv2ᚖgithubᚗcomᚋauthorizerdevᚋauthorizerᚋserverᚋgraphᚋmodelᚐEnv(ctx, field.Selections, res) } +func (ec *executionContext) _Query__webhooks(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + fc := &graphql.FieldContext{ + Object: "Query", + Field: field, + Args: nil, + IsMethod: true, + IsResolver: true, + } + + ctx = graphql.WithFieldContext(ctx, fc) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Query__webhooks_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + fc.Args = args + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Webhooks(rctx, args["params"].(*model.PaginatedInput)) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*model.Webhooks) + fc.Result = res + return ec.marshalNWebhooks2ᚖgithubᚗcomᚋauthorizerdevᚋauthorizerᚋserverᚋgraphᚋmodelᚐWebhooks(ctx, field.Selections, res) +} + +func (ec *executionContext) _Query__webhook_logs(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + fc := &graphql.FieldContext{ + Object: "Query", + Field: field, + Args: nil, + IsMethod: true, + IsResolver: true, + } + + ctx = graphql.WithFieldContext(ctx, fc) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Query__webhook_logs_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + fc.Args = args + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().WebhookLogs(rctx, args["params"].(*model.ListWebhookLogRequest)) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*model.WebhookLogs) + fc.Result = res + return ec.marshalNWebhookLogs2ᚖgithubᚗcomᚋauthorizerdevᚋauthorizerᚋserverᚋgraphᚋmodelᚐWebhookLogs(ctx, field.Selections, res) +} + func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { @@ -6929,6 +7256,568 @@ func (ec *executionContext) _VerificationRequests_verification_requests(ctx cont return ec.marshalNVerificationRequest2ᚕᚖgithubᚗcomᚋauthorizerdevᚋauthorizerᚋserverᚋgraphᚋmodelᚐVerificationRequestᚄ(ctx, field.Selections, res) } +func (ec *executionContext) _Webhook_id(ctx context.Context, field graphql.CollectedField, obj *model.Webhook) (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + fc := &graphql.FieldContext{ + Object: "Webhook", + Field: field, + Args: nil, + IsMethod: false, + IsResolver: false, + } + + ctx = graphql.WithFieldContext(ctx, fc) + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.ID, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNID2string(ctx, field.Selections, res) +} + +func (ec *executionContext) _Webhook_event_name(ctx context.Context, field graphql.CollectedField, obj *model.Webhook) (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + fc := &graphql.FieldContext{ + Object: "Webhook", + Field: field, + Args: nil, + IsMethod: false, + IsResolver: false, + } + + ctx = graphql.WithFieldContext(ctx, fc) + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.EventName, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) _Webhook_endpoint(ctx context.Context, field graphql.CollectedField, obj *model.Webhook) (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + fc := &graphql.FieldContext{ + Object: "Webhook", + Field: field, + Args: nil, + IsMethod: false, + IsResolver: false, + } + + ctx = graphql.WithFieldContext(ctx, fc) + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Endpoint, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) _Webhook_enabled(ctx context.Context, field graphql.CollectedField, obj *model.Webhook) (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + fc := &graphql.FieldContext{ + Object: "Webhook", + Field: field, + Args: nil, + IsMethod: false, + IsResolver: false, + } + + ctx = graphql.WithFieldContext(ctx, fc) + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Enabled, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*bool) + fc.Result = res + return ec.marshalOBoolean2ᚖbool(ctx, field.Selections, res) +} + +func (ec *executionContext) _Webhook_created_at(ctx context.Context, field graphql.CollectedField, obj *model.Webhook) (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + fc := &graphql.FieldContext{ + Object: "Webhook", + Field: field, + Args: nil, + IsMethod: false, + IsResolver: false, + } + + ctx = graphql.WithFieldContext(ctx, fc) + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.CreatedAt, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*int64) + fc.Result = res + return ec.marshalOInt642ᚖint64(ctx, field.Selections, res) +} + +func (ec *executionContext) _Webhook_updated_at(ctx context.Context, field graphql.CollectedField, obj *model.Webhook) (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + fc := &graphql.FieldContext{ + Object: "Webhook", + Field: field, + Args: nil, + IsMethod: false, + IsResolver: false, + } + + ctx = graphql.WithFieldContext(ctx, fc) + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.UpdatedAt, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*int64) + fc.Result = res + return ec.marshalOInt642ᚖint64(ctx, field.Selections, res) +} + +func (ec *executionContext) _WebhookLog_id(ctx context.Context, field graphql.CollectedField, obj *model.WebhookLog) (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + fc := &graphql.FieldContext{ + Object: "WebhookLog", + Field: field, + Args: nil, + IsMethod: false, + IsResolver: false, + } + + ctx = graphql.WithFieldContext(ctx, fc) + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.ID, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNID2string(ctx, field.Selections, res) +} + +func (ec *executionContext) _WebhookLog_http_status(ctx context.Context, field graphql.CollectedField, obj *model.WebhookLog) (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + fc := &graphql.FieldContext{ + Object: "WebhookLog", + Field: field, + Args: nil, + IsMethod: false, + IsResolver: false, + } + + ctx = graphql.WithFieldContext(ctx, fc) + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.HTTPStatus, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOInt322ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) _WebhookLog_response(ctx context.Context, field graphql.CollectedField, obj *model.WebhookLog) (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + fc := &graphql.FieldContext{ + Object: "WebhookLog", + Field: field, + Args: nil, + IsMethod: false, + IsResolver: false, + } + + ctx = graphql.WithFieldContext(ctx, fc) + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Response, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) _WebhookLog_request(ctx context.Context, field graphql.CollectedField, obj *model.WebhookLog) (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + fc := &graphql.FieldContext{ + Object: "WebhookLog", + Field: field, + Args: nil, + IsMethod: false, + IsResolver: false, + } + + ctx = graphql.WithFieldContext(ctx, fc) + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Request, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) _WebhookLog_webhook_id(ctx context.Context, field graphql.CollectedField, obj *model.WebhookLog) (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + fc := &graphql.FieldContext{ + Object: "WebhookLog", + Field: field, + Args: nil, + IsMethod: false, + IsResolver: false, + } + + ctx = graphql.WithFieldContext(ctx, fc) + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.WebhookID, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOID2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) _WebhookLog_created_at(ctx context.Context, field graphql.CollectedField, obj *model.WebhookLog) (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + fc := &graphql.FieldContext{ + Object: "WebhookLog", + Field: field, + Args: nil, + IsMethod: false, + IsResolver: false, + } + + ctx = graphql.WithFieldContext(ctx, fc) + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.CreatedAt, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*int64) + fc.Result = res + return ec.marshalOInt642ᚖint64(ctx, field.Selections, res) +} + +func (ec *executionContext) _WebhookLog_updated_at(ctx context.Context, field graphql.CollectedField, obj *model.WebhookLog) (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + fc := &graphql.FieldContext{ + Object: "WebhookLog", + Field: field, + Args: nil, + IsMethod: false, + IsResolver: false, + } + + ctx = graphql.WithFieldContext(ctx, fc) + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.UpdatedAt, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*int64) + fc.Result = res + return ec.marshalOInt642ᚖint64(ctx, field.Selections, res) +} + +func (ec *executionContext) _WebhookLogs_pagination(ctx context.Context, field graphql.CollectedField, obj *model.WebhookLogs) (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + fc := &graphql.FieldContext{ + Object: "WebhookLogs", + Field: field, + Args: nil, + IsMethod: false, + IsResolver: false, + } + + ctx = graphql.WithFieldContext(ctx, fc) + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Pagination, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*model.Pagination) + fc.Result = res + return ec.marshalNPagination2ᚖgithubᚗcomᚋauthorizerdevᚋauthorizerᚋserverᚋgraphᚋmodelᚐPagination(ctx, field.Selections, res) +} + +func (ec *executionContext) _WebhookLogs_webhook_logs(ctx context.Context, field graphql.CollectedField, obj *model.WebhookLogs) (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + fc := &graphql.FieldContext{ + Object: "WebhookLogs", + Field: field, + Args: nil, + IsMethod: false, + IsResolver: false, + } + + ctx = graphql.WithFieldContext(ctx, fc) + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.WebhookLogs, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.([]*model.WebhookLog) + fc.Result = res + return ec.marshalNWebhookLog2ᚕᚖgithubᚗcomᚋauthorizerdevᚋauthorizerᚋserverᚋgraphᚋmodelᚐWebhookLogᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) _Webhooks_pagination(ctx context.Context, field graphql.CollectedField, obj *model.Webhooks) (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + fc := &graphql.FieldContext{ + Object: "Webhooks", + Field: field, + Args: nil, + IsMethod: false, + IsResolver: false, + } + + ctx = graphql.WithFieldContext(ctx, fc) + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Pagination, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*model.Pagination) + fc.Result = res + return ec.marshalNPagination2ᚖgithubᚗcomᚋauthorizerdevᚋauthorizerᚋserverᚋgraphᚋmodelᚐPagination(ctx, field.Selections, res) +} + +func (ec *executionContext) _Webhooks_webhooks(ctx context.Context, field graphql.CollectedField, obj *model.Webhooks) (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + fc := &graphql.FieldContext{ + Object: "Webhooks", + Field: field, + Args: nil, + IsMethod: false, + IsResolver: false, + } + + ctx = graphql.WithFieldContext(ctx, fc) + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Webhooks, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.([]*model.Webhook) + fc.Result = res + return ec.marshalNWebhook2ᚕᚖgithubᚗcomᚋauthorizerdevᚋauthorizerᚋserverᚋgraphᚋmodelᚐWebhookᚄ(ctx, field.Selections, res) +} + func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { @@ -8213,6 +9102,37 @@ func (ec *executionContext) unmarshalInputInviteMemberInput(ctx context.Context, return it, nil } +func (ec *executionContext) unmarshalInputListWebhookLogRequest(ctx context.Context, obj interface{}) (model.ListWebhookLogRequest, error) { + var it model.ListWebhookLogRequest + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + for k, v := range asMap { + switch k { + case "pagination": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pagination")) + it.Pagination, err = ec.unmarshalNPaginatedInput2ᚖgithubᚗcomᚋauthorizerdevᚋauthorizerᚋserverᚋgraphᚋmodelᚐPaginatedInput(ctx, v) + if err != nil { + return it, err + } + case "webhook_id": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("webhook_id")) + it.WebhookID, err = ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + } + } + + return it, nil +} + func (ec *executionContext) unmarshalInputLoginInput(ctx context.Context, obj interface{}) (model.LoginInput, error) { var it model.LoginInput asMap := map[string]interface{}{} @@ -9881,6 +10801,34 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr } return res }) + case "_webhooks": + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query__webhooks(ctx, field) + if res == graphql.Null { + atomic.AddUint32(&invalids, 1) + } + return res + }) + case "_webhook_logs": + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query__webhook_logs(ctx, field) + if res == graphql.Null { + atomic.AddUint32(&invalids, 1) + } + return res + }) case "__type": out.Values[i] = ec._Query___type(ctx, field) case "__schema": @@ -10130,6 +11078,146 @@ func (ec *executionContext) _VerificationRequests(ctx context.Context, sel ast.S return out } +var webhookImplementors = []string{"Webhook"} + +func (ec *executionContext) _Webhook(ctx context.Context, sel ast.SelectionSet, obj *model.Webhook) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, webhookImplementors) + + out := graphql.NewFieldSet(fields) + var invalids uint32 + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Webhook") + case "id": + out.Values[i] = ec._Webhook_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalids++ + } + case "event_name": + out.Values[i] = ec._Webhook_event_name(ctx, field, obj) + case "endpoint": + out.Values[i] = ec._Webhook_endpoint(ctx, field, obj) + case "enabled": + out.Values[i] = ec._Webhook_enabled(ctx, field, obj) + case "created_at": + out.Values[i] = ec._Webhook_created_at(ctx, field, obj) + case "updated_at": + out.Values[i] = ec._Webhook_updated_at(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalids > 0 { + return graphql.Null + } + return out +} + +var webhookLogImplementors = []string{"WebhookLog"} + +func (ec *executionContext) _WebhookLog(ctx context.Context, sel ast.SelectionSet, obj *model.WebhookLog) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, webhookLogImplementors) + + out := graphql.NewFieldSet(fields) + var invalids uint32 + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("WebhookLog") + case "id": + out.Values[i] = ec._WebhookLog_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalids++ + } + case "http_status": + out.Values[i] = ec._WebhookLog_http_status(ctx, field, obj) + case "response": + out.Values[i] = ec._WebhookLog_response(ctx, field, obj) + case "request": + out.Values[i] = ec._WebhookLog_request(ctx, field, obj) + case "webhook_id": + out.Values[i] = ec._WebhookLog_webhook_id(ctx, field, obj) + case "created_at": + out.Values[i] = ec._WebhookLog_created_at(ctx, field, obj) + case "updated_at": + out.Values[i] = ec._WebhookLog_updated_at(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalids > 0 { + return graphql.Null + } + return out +} + +var webhookLogsImplementors = []string{"WebhookLogs"} + +func (ec *executionContext) _WebhookLogs(ctx context.Context, sel ast.SelectionSet, obj *model.WebhookLogs) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, webhookLogsImplementors) + + out := graphql.NewFieldSet(fields) + var invalids uint32 + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("WebhookLogs") + case "pagination": + out.Values[i] = ec._WebhookLogs_pagination(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalids++ + } + case "webhook_logs": + out.Values[i] = ec._WebhookLogs_webhook_logs(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalids > 0 { + return graphql.Null + } + return out +} + +var webhooksImplementors = []string{"Webhooks"} + +func (ec *executionContext) _Webhooks(ctx context.Context, sel ast.SelectionSet, obj *model.Webhooks) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, webhooksImplementors) + + out := graphql.NewFieldSet(fields) + var invalids uint32 + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Webhooks") + case "pagination": + out.Values[i] = ec._Webhooks_pagination(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalids++ + } + case "webhooks": + out.Values[i] = ec._Webhooks_webhooks(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalids > 0 { + return graphql.Null + } + return out +} + var __DirectiveImplementors = []string{"__Directive"} func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { @@ -10526,6 +11614,11 @@ func (ec *executionContext) unmarshalNOAuthRevokeInput2githubᚗcomᚋauthorizer return res, graphql.ErrorOnPath(ctx, err) } +func (ec *executionContext) unmarshalNPaginatedInput2ᚖgithubᚗcomᚋauthorizerdevᚋauthorizerᚋserverᚋgraphᚋmodelᚐPaginatedInput(ctx context.Context, v interface{}) (*model.PaginatedInput, error) { + res, err := ec.unmarshalInputPaginatedInput(ctx, v) + return &res, graphql.ErrorOnPath(ctx, err) +} + func (ec *executionContext) marshalNPagination2ᚖgithubᚗcomᚋauthorizerdevᚋauthorizerᚋserverᚋgraphᚋmodelᚐPagination(ctx context.Context, sel ast.SelectionSet, v *model.Pagination) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { @@ -10800,6 +11893,142 @@ func (ec *executionContext) unmarshalNVerifyEmailInput2githubᚗcomᚋauthorizer return res, graphql.ErrorOnPath(ctx, err) } +func (ec *executionContext) marshalNWebhook2ᚕᚖgithubᚗcomᚋauthorizerdevᚋauthorizerᚋserverᚋgraphᚋmodelᚐWebhookᚄ(ctx context.Context, sel ast.SelectionSet, v []*model.Webhook) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + fc := &graphql.FieldContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithFieldContext(ctx, fc) + f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalNWebhook2ᚖgithubᚗcomᚋauthorizerdevᚋauthorizerᚋserverᚋgraphᚋmodelᚐWebhook(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + for _, e := range ret { + if e == graphql.Null { + return graphql.Null + } + } + + return ret +} + +func (ec *executionContext) marshalNWebhook2ᚖgithubᚗcomᚋauthorizerdevᚋauthorizerᚋserverᚋgraphᚋmodelᚐWebhook(ctx context.Context, sel ast.SelectionSet, v *model.Webhook) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + return ec._Webhook(ctx, sel, v) +} + +func (ec *executionContext) marshalNWebhookLog2ᚕᚖgithubᚗcomᚋauthorizerdevᚋauthorizerᚋserverᚋgraphᚋmodelᚐWebhookLogᚄ(ctx context.Context, sel ast.SelectionSet, v []*model.WebhookLog) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + fc := &graphql.FieldContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithFieldContext(ctx, fc) + f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalNWebhookLog2ᚖgithubᚗcomᚋauthorizerdevᚋauthorizerᚋserverᚋgraphᚋmodelᚐWebhookLog(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + for _, e := range ret { + if e == graphql.Null { + return graphql.Null + } + } + + return ret +} + +func (ec *executionContext) marshalNWebhookLog2ᚖgithubᚗcomᚋauthorizerdevᚋauthorizerᚋserverᚋgraphᚋmodelᚐWebhookLog(ctx context.Context, sel ast.SelectionSet, v *model.WebhookLog) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + return ec._WebhookLog(ctx, sel, v) +} + +func (ec *executionContext) marshalNWebhookLogs2githubᚗcomᚋauthorizerdevᚋauthorizerᚋserverᚋgraphᚋmodelᚐWebhookLogs(ctx context.Context, sel ast.SelectionSet, v model.WebhookLogs) graphql.Marshaler { + return ec._WebhookLogs(ctx, sel, &v) +} + +func (ec *executionContext) marshalNWebhookLogs2ᚖgithubᚗcomᚋauthorizerdevᚋauthorizerᚋserverᚋgraphᚋmodelᚐWebhookLogs(ctx context.Context, sel ast.SelectionSet, v *model.WebhookLogs) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + return ec._WebhookLogs(ctx, sel, v) +} + +func (ec *executionContext) marshalNWebhooks2githubᚗcomᚋauthorizerdevᚋauthorizerᚋserverᚋgraphᚋmodelᚐWebhooks(ctx context.Context, sel ast.SelectionSet, v model.Webhooks) graphql.Marshaler { + return ec._Webhooks(ctx, sel, &v) +} + +func (ec *executionContext) marshalNWebhooks2ᚖgithubᚗcomᚋauthorizerdevᚋauthorizerᚋserverᚋgraphᚋmodelᚐWebhooks(ctx context.Context, sel ast.SelectionSet, v *model.Webhooks) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + return ec._Webhooks(ctx, sel, v) +} + func (ec *executionContext) marshalN__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v introspection.Directive) graphql.Marshaler { return ec.___Directive(ctx, sel, &v) } @@ -11081,6 +12310,36 @@ func (ec *executionContext) marshalOBoolean2ᚖbool(ctx context.Context, sel ast return graphql.MarshalBoolean(*v) } +func (ec *executionContext) unmarshalOID2ᚖstring(ctx context.Context, v interface{}) (*string, error) { + if v == nil { + return nil, nil + } + res, err := graphql.UnmarshalID(v) + return &res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalOID2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return graphql.MarshalID(*v) +} + +func (ec *executionContext) unmarshalOInt322ᚖstring(ctx context.Context, v interface{}) (*string, error) { + if v == nil { + return nil, nil + } + res, err := graphql.UnmarshalString(v) + return &res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalOInt322ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return graphql.MarshalString(*v) +} + func (ec *executionContext) unmarshalOInt642ᚖint64(ctx context.Context, v interface{}) (*int64, error) { if v == nil { return nil, nil @@ -11096,6 +12355,14 @@ func (ec *executionContext) marshalOInt642ᚖint64(ctx context.Context, sel ast. return graphql.MarshalInt64(*v) } +func (ec *executionContext) unmarshalOListWebhookLogRequest2ᚖgithubᚗcomᚋauthorizerdevᚋauthorizerᚋserverᚋgraphᚋmodelᚐListWebhookLogRequest(ctx context.Context, v interface{}) (*model.ListWebhookLogRequest, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalInputListWebhookLogRequest(ctx, v) + return &res, graphql.ErrorOnPath(ctx, err) +} + func (ec *executionContext) unmarshalOPaginatedInput2ᚖgithubᚗcomᚋauthorizerdevᚋauthorizerᚋserverᚋgraphᚋmodelᚐPaginatedInput(ctx context.Context, v interface{}) (*model.PaginatedInput, error) { if v == nil { return nil, nil diff --git a/server/graph/model/models_gen.go b/server/graph/model/models_gen.go index f4c390b..803ef5e 100644 --- a/server/graph/model/models_gen.go +++ b/server/graph/model/models_gen.go @@ -100,6 +100,11 @@ type InviteMemberInput struct { RedirectURI *string `json:"redirect_uri"` } +type ListWebhookLogRequest struct { + Pagination *PaginatedInput `json:"pagination"` + WebhookID *string `json:"webhook_id"` +} + type LoginInput struct { Email string `json:"email"` Password string `json:"password"` @@ -319,3 +324,32 @@ type VerificationRequests struct { type VerifyEmailInput struct { Token string `json:"token"` } + +type Webhook struct { + ID string `json:"id"` + EventName *string `json:"event_name"` + Endpoint *string `json:"endpoint"` + Enabled *bool `json:"enabled"` + CreatedAt *int64 `json:"created_at"` + UpdatedAt *int64 `json:"updated_at"` +} + +type WebhookLog struct { + ID string `json:"id"` + HTTPStatus *string `json:"http_status"` + Response *string `json:"response"` + Request *string `json:"request"` + WebhookID *string `json:"webhook_id"` + CreatedAt *int64 `json:"created_at"` + UpdatedAt *int64 `json:"updated_at"` +} + +type WebhookLogs struct { + Pagination *Pagination `json:"pagination"` + WebhookLogs []*WebhookLog `json:"webhook_logs"` +} + +type Webhooks struct { + Pagination *Pagination `json:"pagination"` + Webhooks []*Webhook `json:"webhooks"` +} diff --git a/server/graph/schema.graphqls b/server/graph/schema.graphqls index 5855b07..032c8e5 100644 --- a/server/graph/schema.graphqls +++ b/server/graph/schema.graphqls @@ -2,6 +2,7 @@ # # https://gqlgen.com/getting-started/ scalar Int64 +scalar Int32 scalar Map scalar Any @@ -324,6 +325,40 @@ input GenerateJWTKeysInput { type: String! } +type Webhook { + id: ID! + event_name: String + endpoint: String + enabled: Boolean + created_at: Int64 + updated_at: Int64 +} + +type Webhooks { + pagination: Pagination! + webhooks: [Webhook!]! +} + +type WebhookLog { + id: ID! + http_status: Int32 + response: String + request: String + webhook_id: ID + created_at: Int64 + updated_at: Int64 +} + +input ListWebhookLogRequest { + pagination: PaginatedInput! + webhook_id: String +} + +type WebhookLogs { + pagination: Pagination! + webhook_logs: [WebhookLog!]! +} + type Mutation { signup(params: SignUpInput!): AuthResponse! login(params: LoginInput!): AuthResponse! @@ -358,4 +393,6 @@ type Query { _verification_requests(params: PaginatedInput): VerificationRequests! _admin_session: Response! _env: Env! + _webhooks(params: PaginatedInput): Webhooks! + _webhook_logs(params: ListWebhookLogRequest): WebhookLogs! } diff --git a/server/graph/schema.resolvers.go b/server/graph/schema.resolvers.go index 51b2314..5e5cbe3 100644 --- a/server/graph/schema.resolvers.go +++ b/server/graph/schema.resolvers.go @@ -5,6 +5,7 @@ package graph import ( "context" + "fmt" "github.com/authorizerdev/authorizer/server/graph/generated" "github.com/authorizerdev/authorizer/server/graph/model" @@ -123,6 +124,14 @@ func (r *queryResolver) Env(ctx context.Context) (*model.Env, error) { return resolvers.EnvResolver(ctx) } +func (r *queryResolver) Webhooks(ctx context.Context, params *model.PaginatedInput) (*model.Webhooks, error) { + panic(fmt.Errorf("not implemented")) +} + +func (r *queryResolver) WebhookLogs(ctx context.Context, params *model.ListWebhookLogRequest) (*model.WebhookLogs, error) { + panic(fmt.Errorf("not implemented")) +} + // Mutation returns generated.MutationResolver implementation. func (r *Resolver) Mutation() generated.MutationResolver { return &mutationResolver{r} }