Skip to content

Commit

Permalink
Merge pull request #7 from theopenlane/feat-validate-query-length
Browse files Browse the repository at this point in the history
require query to be a minimum of three characters
  • Loading branch information
golanglemonade authored Sep 10, 2024
2 parents e7713c3 + 4f53a87 commit 39ea3ea
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions searchgen/templates/resolver.gotpl
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ func (r *queryResolver) Search(ctx context.Context, query string) (*SearchResult
{{- else }}
func (r *queryResolver) {{ $.Name }}Search(ctx context.Context, query string) (*SearchResultConnection, error) {
{{- end }}
if len(query) < 3 {
return nil, ErrSearchQueryTooShort
}

var (
errors []error
{{- range $object := $.Objects }}
Expand Down

0 comments on commit 39ea3ea

Please sign in to comment.