A query name must be a valid Go identifier https://golang.org/ref/spec#Identifiers
(name string)
| 43 | // |
| 44 | // https://golang.org/ref/spec#Identifiers |
| 45 | func validateQueryName(name string) error { |
| 46 | if len(name) == 0 { |
| 47 | return fmt.Errorf("invalid query name: %q", name) |
| 48 | } |
| 49 | for i, c := range name { |
| 50 | isLetter := unicode.IsLetter(c) || c == '_' |
| 51 | isDigit := unicode.IsDigit(c) |
| 52 | if i == 0 && !isLetter { |
| 53 | return fmt.Errorf("invalid query name %q", name) |
| 54 | } else if !(isLetter || isDigit) { |
| 55 | return fmt.Errorf("invalid query name %q", name) |
| 56 | } |
| 57 | } |
| 58 | return nil |
| 59 | } |
| 60 | |
| 61 | func ParseQueryNameAndType(t string, commentStyle CommentSyntax) (string, string, error) { |
| 62 | for _, line := range strings.Split(t, "\n") { |
no outgoing calls
no test coverage detected