Skip to content

Comments

fix: nodes field returning nil on nested collections#484

Merged
nicolerenee merged 1 commit intoinfratographer:mainfrom
nicolerenee:fix_nodes_on_nested_connection
Aug 6, 2025
Merged

fix: nodes field returning nil on nested collections#484
nicolerenee merged 1 commit intoinfratographer:mainfrom
nicolerenee:fix_nodes_on_nested_connection

Conversation

@nicolerenee
Copy link
Member

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 <code@nicole.dev>
@nicolerenee nicolerenee requested a review from a team as a code owner August 6, 2025 22:06
@nicolerenee nicolerenee requested a review from Copilot August 6, 2025 22:07
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 nodes field 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

Copy link
Contributor

@andy-v-h andy-v-h left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to see some activity here :)

@nicolerenee nicolerenee added this pull request to the merge queue Aug 6, 2025
Merged via the queue into infratographer:main with commit 8050305 Aug 6, 2025
7 checks passed
@nicolerenee nicolerenee deleted the fix_nodes_on_nested_connection branch August 6, 2025 22:52
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants