Skip to content

Commit

Permalink
more pretty print fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
AlecAivazis committed Jul 25, 2019
1 parent 0e7722e commit 2f3bbfb
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
7 changes: 6 additions & 1 deletion printer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}

Expand Down
23 changes: 23 additions & 0 deletions printer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down

0 comments on commit 2f3bbfb

Please sign in to comment.