Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-06-09 18:08:05 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-06-09 18:08:05 +0300
commit6ff3eb60e3ddbfe7450b760efe57112ddacbdb69 (patch)
treed998a13cd56f46b28c542661ea5138da0d4a4e05 /app/graphql
parentea054ec1c398c2903820284df597ccbd14ec2319 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/graphql')
-rw-r--r--app/graphql/types/access_level_enum.rb15
-rw-r--r--app/graphql/types/access_level_type.rb17
-rw-r--r--app/graphql/types/group_member_type.rb17
-rw-r--r--app/graphql/types/member_interface.rb22
-rw-r--r--app/graphql/types/project_member_type.rb13
-rw-r--r--app/graphql/types/user_type.rb6
6 files changed, 86 insertions, 4 deletions
diff --git a/app/graphql/types/access_level_enum.rb b/app/graphql/types/access_level_enum.rb
new file mode 100644
index 00000000000..6754d3d28ce
--- /dev/null
+++ b/app/graphql/types/access_level_enum.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+module Types
+ class AccessLevelEnum < BaseEnum
+ graphql_name 'AccessLevelEnum'
+ description 'Access level to a resource'
+
+ value 'NO_ACCESS', value: Gitlab::Access::NO_ACCESS
+ value 'GUEST', value: Gitlab::Access::GUEST
+ value 'REPORTER', value: Gitlab::Access::REPORTER
+ value 'DEVELOPER', value: Gitlab::Access::DEVELOPER
+ value 'MAINTAINER', value: Gitlab::Access::MAINTAINER
+ value 'OWNER', value: Gitlab::Access::OWNER
+ end
+end
diff --git a/app/graphql/types/access_level_type.rb b/app/graphql/types/access_level_type.rb
new file mode 100644
index 00000000000..c7f915f5038
--- /dev/null
+++ b/app/graphql/types/access_level_type.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+# rubocop:disable Graphql/AuthorizeTypes
+
+module Types
+ class AccessLevelType < Types::BaseObject
+ graphql_name 'AccessLevel'
+ description 'Represents the access level of a relationship between a User and object that it is related to'
+
+ field :integer_value, GraphQL::INT_TYPE, null: true,
+ description: 'Integer representation of access level',
+ method: :to_i
+
+ field :string_value, Types::AccessLevelEnum, null: true,
+ description: 'String representation of access level',
+ method: :to_i
+ end
+end
diff --git a/app/graphql/types/group_member_type.rb b/app/graphql/types/group_member_type.rb
new file mode 100644
index 00000000000..ffffa3247db
--- /dev/null
+++ b/app/graphql/types/group_member_type.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+module Types
+ class GroupMemberType < BaseObject
+ expose_permissions Types::PermissionTypes::Group
+ authorize :read_group
+
+ implements MemberInterface
+
+ graphql_name 'GroupMember'
+ description 'Represents a Group Member'
+
+ field :group, Types::GroupType, null: true,
+ description: 'Group that a User is a member of',
+ resolve: -> (obj, _args, _ctx) { Gitlab::Graphql::Loaders::BatchModelLoader.new(Group, obj.source_id).find }
+ end
+end
diff --git a/app/graphql/types/member_interface.rb b/app/graphql/types/member_interface.rb
new file mode 100644
index 00000000000..976836221bc
--- /dev/null
+++ b/app/graphql/types/member_interface.rb
@@ -0,0 +1,22 @@
+# frozen_string_literal: true
+
+module Types
+ module MemberInterface
+ include BaseInterface
+
+ field :access_level, Types::AccessLevelType, null: true,
+ description: 'GitLab::Access level'
+
+ field :created_by, Types::UserType, null: true,
+ description: 'User that authorized membership'
+
+ field :created_at, Types::TimeType, null: true,
+ description: 'Date and time the membership was created'
+
+ field :updated_at, Types::TimeType, null: true,
+ description: 'Date and time the membership was last updated'
+
+ field :expires_at, Types::TimeType, null: true,
+ description: 'Date and time the membership expires'
+ end
+end
diff --git a/app/graphql/types/project_member_type.rb b/app/graphql/types/project_member_type.rb
index afd95aa5136..e9ccb51886b 100644
--- a/app/graphql/types/project_member_type.rb
+++ b/app/graphql/types/project_member_type.rb
@@ -3,18 +3,23 @@
module Types
class ProjectMemberType < BaseObject
graphql_name 'ProjectMember'
- description 'Member of a project'
+ description 'Represents a Project Member'
+
+ expose_permissions Types::PermissionTypes::Project
+
+ implements MemberInterface
authorize :read_project
field :id, GraphQL::ID_TYPE, null: false,
description: 'ID of the member'
- field :access_level, GraphQL::INT_TYPE, null: false,
- description: 'Access level of the member'
-
field :user, Types::UserType, null: false,
description: 'User that is associated with the member object',
resolve: -> (obj, _args, _ctx) { Gitlab::Graphql::Loaders::BatchModelLoader.new(User, obj.user_id).find }
+
+ field :project, Types::ProjectType, null: true,
+ description: 'Project that User is a member of',
+ resolve: -> (obj, _args, _ctx) { Gitlab::Graphql::Loaders::BatchModelLoader.new(Project, obj.source_id).find }
end
end
diff --git a/app/graphql/types/user_type.rb b/app/graphql/types/user_type.rb
index 04c125592d8..ab3c84ea539 100644
--- a/app/graphql/types/user_type.rb
+++ b/app/graphql/types/user_type.rb
@@ -25,6 +25,12 @@ module Types
field :todos, Types::TodoType.connection_type, null: false,
resolver: Resolvers::TodoResolver,
description: 'Todos of the user'
+ field :group_memberships, Types::GroupMemberType.connection_type, null: true,
+ description: 'Group memberships of the user',
+ method: :group_members
+ field :project_memberships, Types::ProjectMemberType.connection_type, null: true,
+ description: 'Project memberships of the user',
+ method: :project_members
# Merge request field: MRs can be either authored or assigned:
field :authored_merge_requests, Types::MergeRequestType.connection_type, null: true,