Skip to content

Commit

Permalink
CV2-4072: remove TeamUser from UserType
Browse files Browse the repository at this point in the history
  • Loading branch information
melsawy committed Jan 15, 2024
1 parent 43247cb commit bf1bd44
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 223 deletions.
2 changes: 1 addition & 1 deletion app/graph/types/project_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/graph/types/root_level_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
32 changes: 0 additions & 32 deletions app/graph/types/user_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
31 changes: 2 additions & 29 deletions lib/relay.idl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(
"""
Expand Down Expand Up @@ -15713,44 +15713,17 @@ 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!
is_active: Boolean
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
}

Expand Down
162 changes: 2 additions & 160 deletions public/relay.json
Original file line number Diff line number Diff line change
Expand Up @@ -54098,7 +54098,7 @@
],
"type": {
"kind": "OBJECT",
"name": "Team",
"name": "PublicTeam",
"ofType": null
},
"isDeprecated": false,
Expand Down Expand Up @@ -62280,7 +62280,7 @@
],
"type": {
"kind": "OBJECT",
"name": "User",
"name": "Me",
"ofType": null
},
"isDeprecated": false,
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit bf1bd44

Please sign in to comment.