Skip to content

Commit

Permalink
Adding a team_users_count field to GraphQL MeType. (#1987)
Browse files Browse the repository at this point in the history
This new field is not cached, like `number_of_teams`, and can take a `status` argument, this way, it's consistent to be used along with the field `team_users`.

Fixes CV2-4938.
  • Loading branch information
caiosba authored Aug 7, 2024
1 parent 7fabdb7 commit 749447b
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 1 deletion.
8 changes: 8 additions & 0 deletions app/graph/types/me_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,14 @@ def team_users(status: nil)
team_users
end

field :team_users_count, GraphQL::Types::Int, null: true do
argument :status, GraphQL::Types::String, required: false
end

def team_users_count(status: nil)
team_users(status: status).count
end

field :annotations, AnnotationType.connection_type, null: true do
argument :type, GraphQL::Types::String, required: false
end
Expand Down
1 change: 1 addition & 0 deletions lib/relay.idl
Original file line number Diff line number Diff line change
Expand Up @@ -9017,6 +9017,7 @@ type Me implements Node {
last: Int
status: String
): TeamUserConnection
team_users_count(status: String): Int
teams(
"""
Returns the elements in the list that come after the specified cursor.
Expand Down
25 changes: 25 additions & 0 deletions public/relay.json
Original file line number Diff line number Diff line change
Expand Up @@ -49180,6 +49180,31 @@
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "team_users_count",
"description": null,
"args": [
{
"name": "status",
"description": null,
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
},
"defaultValue": null,
"isDeprecated": false,
"deprecationReason": null
}
],
"type": {
"kind": "SCALAR",
"name": "Int",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "teams",
"description": null,
Expand Down
2 changes: 1 addition & 1 deletion test/controllers/graphql_controller_10_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def setup
assert_equal 3, data.size
assert_equal [u.id, u2.id, u3.id], ids.sort
# Quey bot
query = "query { me { dbid, get_send_email_notifications, get_send_successful_login_notifications, get_send_failed_login_notifications, source { medias(first: 1) { edges { node { id } } } }, annotations(first: 1) { edges { node { id } } }, team_users(first: 1) { edges { node { id } } }, bot { get_description, get_role, get_version, get_source_code_url } } }"
query = "query { me { dbid, get_send_email_notifications, get_send_successful_login_notifications, get_send_failed_login_notifications, source { medias(first: 1) { edges { node { id } } } }, annotations(first: 1) { edges { node { id } } }, team_users_count, team_users(first: 1) { edges { node { id } } }, bot { get_description, get_role, get_version, get_source_code_url } } }"
post :create, params: { query: query }
assert_response :success
end
Expand Down

0 comments on commit 749447b

Please sign in to comment.