~emersion/gqlclient

d5fe5efb4df14c1931ef5ae4d98fe3d34ba463cd — Simon Ser 4 months ago d383710
cmd/gqlclientgen: error out on nested aliases

We don't support them right now. Error out if we hit any.
1 files changed, 3 insertions(+), 3 deletions(-)

M cmd/gqlclientgen/main.go
M cmd/gqlclientgen/main.go => cmd/gqlclientgen/main.go +3 -3
@@ 214,6 214,9 @@ func collectFragments(frags map[*ast.FragmentDefinition]struct{}, selSet ast.Sel
	for _, sel := range selSet {
		switch sel := sel.(type) {
		case *ast.Field:
			if sel.Name != sel.Alias {
				panic(fmt.Sprintf("field aliases aren't supported"))
			}
			collectFragments(frags, sel.SelectionSet)
		case *ast.FragmentSpread:
			frags[sel.Definition] = struct{}{}


@@ 262,9 265,6 @@ func genOp(schema *ast.Schema, op *ast.OperationDefinition) *jen.Statement {
		if !ok {
			panic(fmt.Sprintf("unsupported selection %T", sel))
		}
		if field.Name != field.Alias {
			panic(fmt.Sprintf("field aliases aren't supported"))
		}
		typ := genType(schema, field.Definition.Type)
		out = append(out, jen.Id(field.Name).Add(typ))
		ret = append(ret, jen.Id("respData").Dot(strings.Title(field.Name)))