Skip to content

fix: add DatabaseID to parent team GraphQL query to eliminate N+1 REST calls#3384

Open
yoshi-taka wants to merge 1 commit into
integrations:mainfrom
yoshi-taka:fix-team-parent-dbid-gql
Open

fix: add DatabaseID to parent team GraphQL query to eliminate N+1 REST calls#3384
yoshi-taka wants to merge 1 commit into
integrations:mainfrom
yoshi-taka:fix-team-parent-dbid-gql

Conversation

@yoshi-taka
Copy link
Copy Markdown

PR #1452 added the parent object to the teams data source, but parent.id was populated from the GraphQL node ID instead of the numeric database ID, causing issue #2491.

PR #2507 worked around this by adding parent_team_id and parent_team_slug, using a REST GetTeamBySlug call per parent team.

This commit fixes the root cause by adding DatabaseID to the parent team GraphQL query and using it for parent.id. This makes the per-team REST call unnecessary and removes the N+1 pattern.

Resolves #2491


Before the change?

  • parent.id was populated from the GraphQL node ID instead of the numeric database ID.
  • The data source used a REST GetTeamBySlug call per parent team to obtain the numeric parent team ID.
  • This introduced an N+1 API call pattern when listing organization teams with parent teams.

After the change?

  • DatabaseID is included in the parent team GraphQL query.
  • parent.id is populated from the numeric database ID.
  • The per-parent-team REST GetTeamBySlug call is no longer needed.
  • Organization team flattening now avoids the N+1 REST API pattern for parent team IDs.

Pull request checklist

  • Schema migrations have been created if needed (not needed)
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been reviewed and added / updated if needed (not needed)

Does this introduce a breaking change?

Please see our docs on breaking changes to help!

  • Yes
  • No

…T calls

PR integrations#1452 added the parent object to the teams data source, but parent.id was populated from the GraphQL node ID instead of the numeric database ID, causing issue integrations#2491.
PR integrations#2507 worked around this by adding parent_team_id and parent_team_slug, using a REST GetTeamBySlug call per parent team.
This commit fixes the root cause by adding DatabaseID to the parent team GraphQL query and using it for parent.id. This makes the per-team REST call unnecessary and removes the N+1 pattern.
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 1, 2026

👋 Hi! Thank you for this contribution! Just to let you know, our GitHub SDK team does a round of issue and PR reviews twice a week, every Monday and Friday! We have a process in place for prioritizing and responding to your input. Because you are a part of this community please feel free to comment, add to, or pick up any issues/PRs that are labeled with Status: Up for grabs. You & others like you are the reason all of this works! So thank you & happy coding! 🚀

@github-actions github-actions Bot added the Type: Bug Something isn't working as documented label May 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Type: Bug Something isn't working as documented

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]: The github_organization_teams data source doesn't populate parent.id correctly

1 participant