Fix createWebhook endpoint location
This commit is contained in:
+28
-19
@@ -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
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user