From bf1bd445e790b6631a0f2c7bea9265f3bd5bb05c Mon Sep 17 00:00:00 2001 From: Sawy Date: Mon, 15 Jan 2024 20:37:26 +0200 Subject: [PATCH] CV2-4072: remove TeamUser from UserType --- app/graph/types/project_type.rb | 2 +- app/graph/types/root_level_type.rb | 2 +- app/graph/types/user_type.rb | 32 ------ lib/relay.idl | 31 +----- public/relay.json | 162 +---------------------------- 5 files changed, 6 insertions(+), 223 deletions(-) diff --git a/app/graph/types/project_type.rb b/app/graph/types/project_type.rb index 034e30cb4e..ab39118c35 100644 --- a/app/graph/types/project_type.rb +++ b/app/graph/types/project_type.rb @@ -13,7 +13,7 @@ class ProjectType < DefaultObject field :search_id, GraphQL::Types::String, null: true field :url, GraphQL::Types::String, null: true field :search, CheckSearchType, null: true - field :team, TeamType, null: true + field :team, PublicTeamType, null: true field :project_group_id, GraphQL::Types::Int, null: true field :project_group, ProjectGroupType, null: true field :privacy, GraphQL::Types::Int, null: true diff --git a/app/graph/types/root_level_type.rb b/app/graph/types/root_level_type.rb index a1ef5034f5..bc458c7493 100644 --- a/app/graph/types/root_level_type.rb +++ b/app/graph/types/root_level_type.rb @@ -5,7 +5,7 @@ class RootLevelType < BaseObject global_id_field :id - field :current_user, UserType, null: true + field :current_user, MeType, null: true def current_user User.current diff --git a/app/graph/types/user_type.rb b/app/graph/types/user_type.rb index c7ffc7872e..25ca64e475 100644 --- a/app/graph/types/user_type.rb +++ b/app/graph/types/user_type.rb @@ -10,42 +10,10 @@ class UserType < DefaultObject field :last_active_at, GraphQL::Types::Int, null: true field :is_bot, GraphQL::Types::Boolean, null: true field :is_active, GraphQL::Types::Boolean, null: true - field :number_of_teams, GraphQL::Types::Int, null: true - field :accepted_terms, GraphQL::Types::Boolean, null: true - field :current_team_id, GraphQL::Types::Int, null: true field :source, SourceType, null: true def source Source.find(object.source_id) end - - field :current_team, TeamType, null: true - - def current_team - User.current == object ? object.current_team : nil - end - - field :team_user, TeamUserType, null: true do - argument :team_slug, GraphQL::Types::String, required: true, camelize: false - end - - def team_user(team_slug:) - tu = TeamUser - .joins(:team) - .where("teams.slug" => team_slug, :user_id => object.id) - .last - tu.nil? ? nil : TeamUser.find_if_can(tu.id, context[:ability]) - end - - field :team_users, TeamUserType.connection_type, null: true do - argument :status, GraphQL::Types::String, required: false - end - - def team_users(status: nil) - return TeamUser.none unless object == User.current - team_users = object.team_users - team_users = team_users.where(status: status) if status - team_users - end end diff --git a/lib/relay.idl b/lib/relay.idl index 5fad185ae0..a5f3f6668a 100644 --- a/lib/relay.idl +++ b/lib/relay.idl @@ -10011,7 +10011,7 @@ type Project implements Node { pusher_channel: String search: CheckSearch search_id: String - team: Team + team: PublicTeam title: String! updated_at: String url: String @@ -11829,7 +11829,7 @@ Unassociated root object queries """ type RootLevel implements Node { current_team: Team - current_user: User + current_user: Me id: ID! team_bots_listed( """ @@ -15713,10 +15713,7 @@ type UpdateUserPayload { User type """ type User implements Node { - accepted_terms: Boolean created_at: String - current_team: Team - current_team_id: Int dbid: Int email: String id: ID! @@ -15724,33 +15721,9 @@ type User implements Node { is_bot: Boolean last_active_at: Int name: String - number_of_teams: Int permissions: String profile_image: String source: Source - team_user(team_slug: String!): TeamUser - team_users( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: String - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: String - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the last _n_ elements from the list. - """ - last: Int - status: String - ): TeamUserConnection updated_at: String } diff --git a/public/relay.json b/public/relay.json index f597c39f4b..c6eddfed3b 100644 --- a/public/relay.json +++ b/public/relay.json @@ -54098,7 +54098,7 @@ ], "type": { "kind": "OBJECT", - "name": "Team", + "name": "PublicTeam", "ofType": null }, "isDeprecated": false, @@ -62280,7 +62280,7 @@ ], "type": { "kind": "OBJECT", - "name": "User", + "name": "Me", "ofType": null }, "isDeprecated": false, @@ -86558,20 +86558,6 @@ "name": "User", "description": "User type", "fields": [ - { - "name": "accepted_terms", - "description": null, - "args": [ - - ], - "type": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, { "name": "created_at", "description": null, @@ -86586,34 +86572,6 @@ "isDeprecated": false, "deprecationReason": null }, - { - "name": "current_team", - "description": null, - "args": [ - - ], - "type": { - "kind": "OBJECT", - "name": "Team", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "current_team_id", - "description": null, - "args": [ - - ], - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, { "name": "dbid", "description": null, @@ -86716,20 +86674,6 @@ "isDeprecated": false, "deprecationReason": null }, - { - "name": "number_of_teams", - "description": null, - "args": [ - - ], - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, { "name": "permissions", "description": null, @@ -86772,108 +86716,6 @@ "isDeprecated": false, "deprecationReason": null }, - { - "name": "team_user", - "description": null, - "args": [ - { - "name": "team_slug", - "description": null, - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "defaultValue": null, - "isDeprecated": false, - "deprecationReason": null - } - ], - "type": { - "kind": "OBJECT", - "name": "TeamUser", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "team_users", - "description": null, - "args": [ - { - "name": "after", - "description": "Returns the elements in the list that come after the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "before", - "description": "Returns the elements in the list that come before the specified cursor.", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "first", - "description": "Returns the first _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "last", - "description": "Returns the last _n_ elements from the list.", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "status", - "description": null, - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null, - "isDeprecated": false, - "deprecationReason": null - } - ], - "type": { - "kind": "OBJECT", - "name": "TeamUserConnection", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, { "name": "updated_at", "description": null,