From 2f3bbfb55c5c92e900b4e02f41fa125d6f170b43 Mon Sep 17 00:00:00 2001 From: Alec Aivazis Date: Thu, 25 Jul 2019 09:22:16 -0700 Subject: [PATCH] more pretty print fixes --- printer.go | 7 ++++++- printer_test.go | 23 +++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/printer.go b/printer.go index e2fd6d0..77d4093 100644 --- a/printer.go +++ b/printer.go @@ -301,10 +301,15 @@ func printerBuildType(from *ast.Type) (gAst.Type, error) { // check if we have a list if from.Elem != nil { + innerType, err := printerBuildType(from.Elem) + if err != nil { + return nil, err + } + // wrap the element in a list finalType = &gAst.List{ Kind: "List", - Type: finalType, + Type: innerType, } } diff --git a/printer_test.go b/printer_test.go index ec64c25..20039ae 100644 --- a/printer_test.go +++ b/printer_test.go @@ -632,6 +632,29 @@ fragment Foo on User { }, }, }, + }, { + `query foo($id: [String!]) { + hello +} +`, + &ast.QueryDocument{ + Operations: ast.OperationList{&ast.OperationDefinition{ + Operation: ast.Query, + Name: "foo", + SelectionSet: ast.SelectionSet{ + &ast.Field{ + Name: "hello", + }, + }, + VariableDefinitions: ast.VariableDefinitionList{ + &ast.VariableDefinition{ + Variable: "id", + Type: ast.ListType(ast.NonNullNamedType("String", &ast.Position{}), &ast.Position{}), + }, + }, + }, + }, + }, }, // single mutation field {