Skip to content

Commit 8050305

Browse files
authored
fix: nodes field returning nil on nested collections (#484)
The upstream PR ent/contrib#602 appears to have missed adding the check for the `nodes` field being used in the collections template. This is used when you call a collection from another collection, for example: ``` query { loadBalancer(id: "lb-123"){ ports { nodes { pools { nodes { id } } } } } } ``` Before this fix the `pools.nodes` would come back as an empty list, with this fix it's properly filled out. Signed-off-by: Nicole Hubbard <[email protected]>
1 parent 85ef39f commit 8050305

File tree

3 files changed

+442
-1
lines changed

3 files changed

+442
-1
lines changed

entx/generator.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func WithFederation() ExtensionOption {
4747
// WithConnectionNodes adds the templates for adding nodes to relay connections
4848
func WithConnectionNodes() ExtensionOption {
4949
return func(ex *Extension) error {
50-
ex.templates = append(ex.templates, PaginationTemplate)
50+
ex.templates = append(ex.templates, PaginationTemplate, CollectionTemplate)
5151
ex.gqlSchemaHooks = append(ex.gqlSchemaHooks, addNodesToConnections)
5252

5353
return nil

entx/template.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ var (
3434
// PaginationTemplate adds support for adding the nodes field to relay connections
3535
PaginationTemplate = parseT("template/pagination.tmpl")
3636

37+
// CollectionTemplate adds support for adding the nodes field to relay connections
38+
CollectionTemplate = parseT("template/collection.tmpl")
39+
3740
// TemplateFuncs contains the extra template functions used by entx.
3841
TemplateFuncs = template.FuncMap{
3942
"contains": strings.Contains,

0 commit comments

Comments
 (0)