diff --git a/generate/testdata/queries/ListOfListsOfLists.graphql b/generate/testdata/queries/ListOfListsOfLists.graphql new file mode 100644 index 0000000..b56ee7c --- /dev/null +++ b/generate/testdata/queries/ListOfListsOfLists.graphql @@ -0,0 +1,3 @@ +query ListOfListsOfLists { + listOfListsOfLists +} diff --git a/generate/testdata/queries/ListOfListsOfLists.graphql.go b/generate/testdata/queries/ListOfListsOfLists.graphql.go new file mode 100644 index 0000000..88b8450 --- /dev/null +++ b/generate/testdata/queries/ListOfListsOfLists.graphql.go @@ -0,0 +1,29 @@ +package test + +// Code generated by github.com/Khan/genqlient, DO NOT EDIT. + +import ( + "github.com/Khan/genqlient/graphql" +) + +type ListOfListsOfListsResponse struct { + ListOfListsOfLists [][][]string `json:"listOfListsOfLists"` +} + +func ListOfListsOfLists( + client graphql.Client, +) (*ListOfListsOfListsResponse, error) { + var retval ListOfListsOfListsResponse + err := client.MakeRequest( + nil, + "ListOfListsOfLists", + ` +query ListOfListsOfLists { + listOfListsOfLists +} +`, + &retval, + nil, + ) + return &retval, err +} diff --git a/generate/testdata/queries/ListOfListsOfLists.graphql.json b/generate/testdata/queries/ListOfListsOfLists.graphql.json new file mode 100644 index 0000000..083f03b --- /dev/null +++ b/generate/testdata/queries/ListOfListsOfLists.graphql.json @@ -0,0 +1,9 @@ +{ + "operations": [ + { + "operationName": "ListOfListsOfLists", + "query": "\nquery ListOfListsOfLists {\n\tlistOfListsOfLists\n}\n", + "sourceLocation": "testdata/queries/ListOfListsOfLists.graphql" + } + ] +} \ No newline at end of file diff --git a/generate/testdata/queries/schema.graphql b/generate/testdata/queries/schema.graphql index 987a633..5e334bc 100644 --- a/generate/testdata/queries/schema.graphql +++ b/generate/testdata/queries/schema.graphql @@ -67,6 +67,7 @@ type Query { convert(dt: DateTime!, tz: String): DateTime! maybeConvert(dt: DateTime, tz: String): DateTime getJunk: Junk + listOfListsOfLists: [[[String!]!]!]! } type Mutation { diff --git a/generate/types.go b/generate/types.go index 5f8ac46..0f92ef8 100644 --- a/generate/types.go +++ b/generate/types.go @@ -292,14 +292,15 @@ func (builder *typeBuilder) writeType(name, namePrefix string, typ *ast.Type, fi // gqlgen does slightly different things here, but its implementation may // be useful to crib from: // https://github.com/99designs/gqlgen/blob/master/plugin/modelgen/models.go#L113 - if typ.Elem != nil { // XXX: this should be for, not if + for typ.Elem != nil { // Type is a list. builder.WriteString("[]") typ = typ.Elem } if options.GetPointer() { // TODO: this does []*T, you might in principle want *[]T or - // *[]*T. We could add a "sliceptr" option if it comes up. + // *[]*T. We could add a "sliceptr" option if it comes up (that's + // still not correct if you wanted *[][]*[]T, but, like, tough luck). builder.WriteString("*") }