diff options
Diffstat (limited to 'app/graphql/types/access_levels')
-rw-r--r-- | app/graphql/types/access_levels/deploy_key_type.rb | 32 | ||||
-rw-r--r-- | app/graphql/types/access_levels/user_type.rb | 61 |
2 files changed, 93 insertions, 0 deletions
diff --git a/app/graphql/types/access_levels/deploy_key_type.rb b/app/graphql/types/access_levels/deploy_key_type.rb new file mode 100644 index 00000000000..e4e90619891 --- /dev/null +++ b/app/graphql/types/access_levels/deploy_key_type.rb @@ -0,0 +1,32 @@ +# frozen_string_literal: true + +module Types + module AccessLevels + class DeployKeyType < BaseObject + graphql_name 'AccessLevelDeployKey' + description 'Representation of a GitLab deploy key.' + + authorize :read_deploy_key + + field :id, + type: GraphQL::Types::ID, + null: false, + description: 'ID of the deploy key.' + + field :title, + type: GraphQL::Types::String, + null: false, + description: 'Title of the deploy key.' + + field :expires_at, + type: Types::DateType, + null: true, + description: 'Expiration date of the deploy key.' + + field :user, + type: Types::AccessLevels::UserType, + null: false, + description: 'User assigned to the deploy key.' + end + end +end diff --git a/app/graphql/types/access_levels/user_type.rb b/app/graphql/types/access_levels/user_type.rb new file mode 100644 index 00000000000..82aba673250 --- /dev/null +++ b/app/graphql/types/access_levels/user_type.rb @@ -0,0 +1,61 @@ +# frozen_string_literal: true + +module Types + module AccessLevels + class UserType < BaseObject + graphql_name 'AccessLevelUser' + description 'Representation of a GitLab user.' + + authorize :read_user + + present_using UserPresenter + + field :id, + type: GraphQL::Types::ID, + null: false, + description: 'ID of the user.' + + field :username, + type: GraphQL::Types::String, + null: false, + description: 'Username of the user.' + + field :name, + type: GraphQL::Types::String, + null: false, + resolver_method: :redacted_name, + description: <<~DESC + Human-readable name of the user. + Returns `****` if the user is a project bot and the requester does not have permission to view the project. + DESC + + field :public_email, + type: GraphQL::Types::String, + null: true, + description: "User's public email." + + field :avatar_url, + type: GraphQL::Types::String, + null: true, + description: "URL of the user's avatar." + + field :web_url, + type: GraphQL::Types::String, + null: false, + description: 'Web URL of the user.' + + field :web_path, + type: GraphQL::Types::String, + null: false, + description: 'Web path of the user.' + + def redacted_name + object.redacted_name(context[:current_user]) + end + + def avatar_url + object.avatar_url(only_path: false) + end + end + end +end |