fix: nodes field returning nil on nested collections#484
Merged
nicolerenee merged 1 commit intoinfratographer:mainfrom Aug 6, 2025
Merged
Conversation
Signed-off-by: Nicole Hubbard <code@nicole.dev>
There was a problem hiding this comment.
Pull Request Overview
This PR fixes an issue where the nodes field was returning nil on nested collections in GraphQL queries. The fix adds support for the nodes field check in the collection template, ensuring that nested collection queries properly populate the nodes field instead of returning empty lists.
- Adds a new collection template with the necessary
nodesfield support - Registers the collection template in the generator's WithConnectionNodes extension
- Includes the missing check for
hasCollectedField(ctx, append(path, nodesField)...)in the template logic
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| entx/template/collection.tmpl | New template file that adds nodes field support to collections with the critical fix on line 94 |
| entx/template.go | Adds CollectionTemplate variable to register the new template |
| entx/generator.go | Updates WithConnectionNodes to include the CollectionTemplate alongside PaginationTemplate |
andy-v-h
approved these changes
Aug 6, 2025
Contributor
andy-v-h
left a comment
There was a problem hiding this comment.
Good to see some activity here :)
github-merge-queue bot
pushed a commit
that referenced
this pull request
Aug 6, 2025
🤖 I have created a release *beep* *boop* --- ## [0.13.1](v0.13.0...v0.13.1) (2025-08-06) ### Bug Fixes * **deps:** update module entgo.io/contrib to v0.7.0 ([#478](#478)) ([9c1ef02](9c1ef02)) * **deps:** update module entgo.io/ent to v0.14.5 ([#476](#476)) ([9cb7a80](9cb7a80)) * **deps:** update module github.com/golang-jwt/jwt/v5 to v5.3.0 ([#473](#473)) ([ef4a0ee](ef4a0ee)) * **deps:** update module github.com/micahparks/keyfunc/v3 to v3.5.0 ([#480](#480)) ([61b2e8e](61b2e8e)) * **deps:** update module github.com/micahparks/keyfunc/v3 to v3.6.1 ([#481](#481)) ([648df78](648df78)) * **deps:** update module github.com/nats-io/nats-server/v2 to v2.11.7 ([#477](#477)) ([d3411df](d3411df)) * **deps:** update module go.step.sm/crypto to v0.68.0 ([#475](#475)) ([c6479f5](c6479f5)) * **deps:** update module go.step.sm/crypto to v0.69.0 ([#483](#483)) ([85ef39f](85ef39f)) * nodes field returning nil on nested collections ([#484](#484)) ([8050305](8050305)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Signed-off-by: Infratographer Robot <github-robot@infratographer.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The upstream PR ent/contrib#602 appears to have missed adding the check for the
nodesfield being used in the collections template. This is used when you call a collection from another collection, for example:Before this fix the
pools.nodeswould come back as an empty list, with this fix it's properly filled out.