Fix repo visibility change API not working

During the upgrade to `gqlgen` version 1.17.42 a breaking change was
introduced, as `map[string]interface{}` values were changed to be type
checked in 1.17.40 (commit 74e918f9, PR
https://github.com/99designs/gqlgen/pull/2830).  As Emersion noted,
changing `OptionalString` to `Optional` fixes this.

Additionally, I replaced the "placeholder" error message with something
a bit more descriptive as a stopgap measure.
This commit is contained in:
KAAtheWise 2024-01-19 15:52:34 +00:00 committed by Drew DeVault
parent d1957c458d
commit adc6fbc160
1 changed files with 5 additions and 5 deletions

View File

@ -134,7 +134,7 @@ func (r *mutationResolver) CreateRepository(ctx context.Context, name string, vi
NOW() at time zone 'utc',
NOW() at time zone 'utc',
$1, $2, $3, $4, $5, $6
) RETURNING
) RETURNING
id, created, updated, name, description, visibility,
path, owner_id;
`, name, description, repoPath, visibility, user.UserID, cloneStatus)
@ -304,7 +304,7 @@ func (r *mutationResolver) UpdateRepository(ctx context.Context, id int, input m
row := tx.QueryRowContext(ctx, `
INSERT INTO redirect (
created, name, path, owner_id, new_repo_id
) SELECT
) SELECT
NOW() at time zone 'utc',
orig.name, orig.path, orig.owner_id, orig.id
FROM repository orig
@ -349,7 +349,7 @@ func (r *mutationResolver) UpdateRepository(ctx context.Context, id int, input m
}
})
validation.OptionalString("visibility", func(vis string) {
validation.Optional("visibility", func(vis interface{}) {
query = query.Set(`visibility`, vis)
})
@ -362,7 +362,7 @@ func (r *mutationResolver) UpdateRepository(ctx context.Context, id int, input m
})
if !validation.Ok() {
return errors.New("placeholder") // TODO: Avoid surfacing placeholder error
return errors.New("validation failed") // TODO: Avoid surfacing placeholder error
}
query = query.
@ -403,7 +403,7 @@ func (r *mutationResolver) UpdateRepository(ctx context.Context, id int, input m
})
if !validation.Ok() {
return errors.New("placeholder") // TODO: Avoid surfacing placeholder error
return errors.New("validation failed") // TODO: Avoid surfacing placeholder error
}
export := path.Join(repo.Path, "git-daemon-export-ok")