operationName resolves the requested operation, or the document's sole operation when no name is supplied. Invalid selections retain the supplied name without claiming a kind or selecting a different operation.
(query, selected string)
| 90 | // operation when no name is supplied. Invalid selections retain the supplied |
| 91 | // name without claiming a kind or selecting a different operation. |
| 92 | func operationName(query, selected string) (kind, name string) { |
| 93 | doc, err := parser.ParseQuery(&ast.Source{Input: query}) |
| 94 | if err != nil { |
| 95 | return "", selected |
| 96 | } |
| 97 | op := doc.Operations.ForName(selected) |
| 98 | if op == nil { |
| 99 | return "", selected |
| 100 | } |
| 101 | return string(op.Operation), op.Name |
| 102 | } |