Fix createWebhook endpoint location

This commit is contained in:
2023-01-20 23:03:59 -07:00
parent 4a4b6fd185
commit c1d4f3cc16
+28 -19
View File
@@ -92,25 +92,6 @@ func createSchema(db database.Database) (graphql.Schema, error) {
return nil, nil
},
},
"createWebhook": &graphql.Field{
Type: webhookType,
Description: "Create a new webhook",
Args: graphql.FieldConfigArgument{
"type": &graphql.ArgumentConfig{
Type: graphql.NewNonNull(graphql.String),
},
},
Resolve: func(params graphql.ResolveParams) (interface{}, error) {
webhook, err := db.CreateWebhook(
database.WebhookSender(params.Args["type"].(string)),
params.Source.(database.Pipeline).Id,
)
if err != nil {
return nil, err
}
return webhook, nil
},
},
"webhooks": &graphql.Field{
Type: graphql.NewNonNull(graphql.NewList(graphql.NewNonNull(webhookType))),
Description: "The list of webhooks for the pipeline.",
@@ -181,6 +162,34 @@ func createSchema(db database.Database) (graphql.Schema, error) {
return pipeline, nil
},
},
"createWebhook": &graphql.Field{
Type: webhookType,
Description: "Create a new webhook",
Args: graphql.FieldConfigArgument{
"type": &graphql.ArgumentConfig{
Type: graphql.NewNonNull(graphql.String),
},
"pipeline_id": &graphql.ArgumentConfig{
Type: graphql.NewNonNull(graphql.String),
},
},
Resolve: func(params graphql.ResolveParams) (interface{}, error) {
id, err := uuid.Parse(params.Args["id"].(string))
if err != nil {
return nil, err
}
webhook, err := db.CreateWebhook(
database.WebhookSender(params.Args["type"].(string)),
id,
)
if err != nil {
return nil, err
}
return webhook, nil
},
},
},
})