Add tags and teams to User struct and hydrate them in ListUsers#614
Merged
saditya370 merged 3 commits intomainfrom May 5, 2026
Merged
Add tags and teams to User struct and hydrate them in ListUsers#614saditya370 merged 3 commits intomainfrom
saditya370 merged 3 commits intomainfrom
Conversation
| } | ||
|
|
||
| func (user *User) Teams(client *Client, variables *PayloadVariables) (*TeamIdConnection, error) { | ||
| func (user *User) GetTeams(client *Client, variables *PayloadVariables) (*TeamIdConnection, error) { |
Contributor
There was a problem hiding this comment.
Can we do this without changing this method name? We'll have update the major version we change this.
Contributor
Author
There was a problem hiding this comment.
@andrewstillv15 Renamed the struct field to TeamsConnection with an explicit graphql:"teams" tag instead, which keeps User.Teams intact
andrewstillv15
approved these changes
May 5, 2026
| return &q.Account.User.Teams, nil | ||
| } | ||
|
|
||
| func (user *User) Hydrate(client *Client) error { |
Contributor
There was a problem hiding this comment.
Nit
Suggested change
| func (user *User) Hydrate(client *Client) error { | |
| func (user *User) hydrate(client *Client) error { |
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.
Summary
Adds
Tags *TagConnectionandTeams *TeamIdConnectionto theUserstruct soListUsersreturns tag and team-membership data inline, mirroring the precedent onService. Without this, callers (notably the OpsLevel MCP server) cannot answer questions like "which team does this user belong to?" or "which users are tagged as on-call leads?" without a follow-up query per user.Changes
object.goUsergains two pointer-typed connection fields:Tags *TagConnection(json:"tags,omitempty")Teams *TeamIdConnection(json:"teams,omitempty")These match the pattern used on
Service.Tags. The graphql library auto-generates the inline selection set from the struct, soListUsersnow requeststags{nodes{id,key,value},pageInfo}andteams{nodes{alias,id},pageInfo}per user node.user.goUser.Teams(...)→User.GetTeams(...)to free theTeamsfield name. The previous method name collided with the new struct field. Aligns naming withUserId.GetTags.User.Hydrate(client)follows pagination on the embeddedTagsandTeamsconnections when their innerpageInfo.hasNextPageistrue. MirrorsService.Hydrate.ListUsersnow invokesHydrateon every node from the initial query — not just nodes merged from recursive list pages. This closes a silent-truncation bug: previously, if every user fit on the first outer page (the common case for small accounts), no user ever had its inner tag/team pagination followed, capping users at the schema-default 500 nodes per inner connection without a follow-up.Tests
user_test.gotags/teamsselections under each user node.TestListUserPopulatesTagsAndTeams— asserts the inline path works: a user returned fromListUserswith embedded tags+teams JSON gets those fields populated on the Go struct.TestListUserHydratesFirstPageInnerConnections— regression for the first-page hydration fix. Setstags.pageInfo.hasNextPage=trueon a user returned in the first outer page and asserts a follow-upUserTagsListquery is issued and the merged tag list is returned.team_test.go,cache_test.go,actions_test.go,clientGQL_test.goEvery test that selects
Useras a sub-field (Team.Manager,deletedMembers) now expectstags{...}andteams{...}inside themanager{...}(or equivalent) selection. Same pattern in all four files.testdata/templates/query/team/get.tplThe shared
team_gettemplate'smanager{...}block was extended withtagsandteamsconnection selections to match the newUsershape.Notes
TeamIdConnection(notTeamConnection) is used for the inline selection — minimal{alias, id}per team. Teamnameis intentionally not added; most callers can use the alias as a stable identifier.tags{...}/teams{...}selections rely on the schema'sdefault_page_size: 100/default_max_page_size: 500.HydratefollowshasNextPagefor both, so power users with overflowing tags/teams are still fully populated.Test plan
go test ./...passesTestListUserPopulatesTagsAndTeamscovers the inline pathTestListUserHydratesFirstPageInnerConnectionscovers the first-page hydration fix