diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-08-20 18:42:06 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-08-20 18:42:06 +0000 |
commit | 6e4e1050d9dba2b7b2523fdd1768823ab85feef4 (patch) | |
tree | 78be5963ec075d80116a932011d695dd33910b4e /app/graphql/types | |
parent | 1ce776de4ae122aba3f349c02c17cebeaa8ecf07 (diff) | |
download | gitlab-ce-6e4e1050d9dba2b7b2523fdd1768823ab85feef4.tar.gz |
Add latest changes from gitlab-org/gitlab@13-3-stable-ee
Diffstat (limited to 'app/graphql/types')
34 files changed, 293 insertions, 134 deletions
diff --git a/app/graphql/types/alert_management/alert_type.rb b/app/graphql/types/alert_management/alert_type.rb index 089d2426158..1a0b0685ffe 100644 --- a/app/graphql/types/alert_management/alert_type.rb +++ b/app/graphql/types/alert_management/alert_type.rb @@ -71,7 +71,7 @@ module Types description: 'Number of events of this alert', method: :events - field :details, + field :details, # rubocop:disable Graphql/JSONType GraphQL::Types::JSON, null: true, description: 'Alert details' @@ -94,8 +94,28 @@ module Types field :metrics_dashboard_url, GraphQL::STRING_TYPE, null: true, - description: 'URL for metrics embed for the alert', - resolve: -> (alert, _args, _context) { alert.present.metrics_dashboard_url } + description: 'URL for metrics embed for the alert' + + field :runbook, + GraphQL::STRING_TYPE, + null: true, + description: 'Runbook for the alert as defined in alert details' + + field :todos, + Types::TodoType.connection_type, + null: true, + description: 'Todos of the current user for the alert', + resolver: Resolvers::TodoResolver + + field :details_url, + GraphQL::STRING_TYPE, + null: false, + description: 'The URL of the alert detail page' + + field :prometheus_alert, + Types::PrometheusAlertType, + null: true, + description: 'The alert condition for Prometheus' def notes object.ordered_notes diff --git a/app/graphql/types/board_list_type.rb b/app/graphql/types/board_list_type.rb index e94ff898807..70c0794fc90 100644 --- a/app/graphql/types/board_list_type.rb +++ b/app/graphql/types/board_list_type.rb @@ -3,6 +3,8 @@ module Types # rubocop: disable Graphql/AuthorizeTypes class BoardListType < BaseObject + include Gitlab::Utils::StrongMemoize + graphql_name 'BoardList' description 'Represents a list for an issue board' @@ -19,6 +21,31 @@ module Types field :collapsed, GraphQL::BOOLEAN_TYPE, null: true, description: 'Indicates if list is collapsed for this user', resolve: -> (list, _args, ctx) { list.collapsed?(ctx[:current_user]) } + field :issues_count, GraphQL::INT_TYPE, null: true, + description: 'Count of issues in the list' + + field :issues, ::Types::IssueType.connection_type, null: true, + description: 'Board issues', + resolver: ::Resolvers::BoardListIssuesResolver + + def issues_count + metadata[:size] + end + + def total_weight + metadata[:total_weight] + end + + def metadata + strong_memoize(:metadata) do + list = self.object + user = context[:current_user] + + Boards::Issues::ListService + .new(list.board.resource_parent, user, board_id: list.board_id, id: list.id) + .metadata + end + end end # rubocop: enable Graphql/AuthorizeTypes end diff --git a/app/graphql/types/ci/group_type.rb b/app/graphql/types/ci/group_type.rb new file mode 100644 index 00000000000..04c0eb93068 --- /dev/null +++ b/app/graphql/types/ci/group_type.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +module Types + module Ci + # rubocop: disable Graphql/AuthorizeTypes + class GroupType < BaseObject + graphql_name 'CiGroup' + + field :name, GraphQL::STRING_TYPE, null: true, + description: 'Name of the job group' + field :size, GraphQL::INT_TYPE, null: true, + description: 'Size of the group' + field :jobs, Ci::JobType.connection_type, null: true, + description: 'Jobs in group' + end + end +end diff --git a/app/graphql/types/ci/job_type.rb b/app/graphql/types/ci/job_type.rb new file mode 100644 index 00000000000..4c18f3ffd52 --- /dev/null +++ b/app/graphql/types/ci/job_type.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +module Types + module Ci + # rubocop: disable Graphql/AuthorizeTypes + class JobType < BaseObject + graphql_name 'CiJob' + + field :name, GraphQL::STRING_TYPE, null: true, + description: 'Name of the job' + field :needs, JobType.connection_type, null: true, + description: 'Builds that must complete before the jobs run' + end + end +end diff --git a/app/graphql/types/ci/pipeline_config_source_enum.rb b/app/graphql/types/ci/pipeline_config_source_enum.rb new file mode 100644 index 00000000000..48f88c133b4 --- /dev/null +++ b/app/graphql/types/ci/pipeline_config_source_enum.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +module Types + module Ci + class PipelineConfigSourceEnum < BaseEnum + ::Ci::PipelineEnums.config_sources.keys.each do |state_symbol| + value state_symbol.to_s.upcase, value: state_symbol.to_s + end + end + end +end diff --git a/app/graphql/types/ci/pipeline_type.rb b/app/graphql/types/ci/pipeline_type.rb index 32050766e5b..82a9f8495ce 100644 --- a/app/graphql/types/ci/pipeline_type.rb +++ b/app/graphql/types/ci/pipeline_type.rb @@ -5,6 +5,8 @@ module Types class PipelineType < BaseObject graphql_name 'Pipeline' + connection_type_class(Types::CountableConnectionType) + authorize :read_pipeline expose_permissions Types::PermissionTypes::Ci::Pipeline @@ -23,6 +25,8 @@ module Types field :detailed_status, Types::Ci::DetailedStatusType, null: false, description: 'Detailed status of the pipeline', resolve: -> (obj, _args, ctx) { obj.detailed_status(ctx[:current_user]) } + field :config_source, PipelineConfigSourceEnum, null: true, + description: "Config source of the pipeline (#{::Ci::PipelineEnums.config_sources.keys.join(', ').upcase})" field :duration, GraphQL::INT_TYPE, null: true, description: 'Duration of the pipeline in seconds' field :coverage, GraphQL::FLOAT_TYPE, null: true, @@ -37,8 +41,13 @@ module Types description: "Timestamp of the pipeline's completion" field :committed_at, Types::TimeType, null: true, description: "Timestamp of the pipeline's commit" - - # TODO: Add triggering user as a type + field :stages, Types::Ci::StageType.connection_type, null: true, + description: 'Stages of the pipeline', + extras: [:lookahead], + resolver: Resolvers::Ci::PipelineStagesResolver + field :user, Types::UserType, null: true, + description: 'Pipeline user', + resolve: -> (pipeline, _args, _context) { Gitlab::Graphql::Loaders::BatchModelLoader.new(User, pipeline.user_id).find } end end end diff --git a/app/graphql/types/ci/stage_type.rb b/app/graphql/types/ci/stage_type.rb new file mode 100644 index 00000000000..278c4d4d748 --- /dev/null +++ b/app/graphql/types/ci/stage_type.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +module Types + module Ci + # rubocop: disable Graphql/AuthorizeTypes + class StageType < BaseObject + graphql_name 'CiStage' + + field :name, GraphQL::STRING_TYPE, null: true, + description: 'Name of the stage' + field :groups, Ci::GroupType.connection_type, null: true, + description: 'Group of jobs for the stage' + end + end +end diff --git a/app/graphql/types/ci_configuration/sast/analyzers_entity_type.rb b/app/graphql/types/ci_configuration/sast/analyzers_entity_type.rb deleted file mode 100644 index ccd1c7dd0eb..00000000000 --- a/app/graphql/types/ci_configuration/sast/analyzers_entity_type.rb +++ /dev/null @@ -1,25 +0,0 @@ -# frozen_string_literal: true - -module Types - module CiConfiguration - module Sast - # rubocop: disable Graphql/AuthorizeTypes - class AnalyzersEntityType < BaseObject - graphql_name 'SastCiConfigurationAnalyzersEntity' - description 'Represents an analyzer entity in SAST CI configuration' - - field :name, GraphQL::STRING_TYPE, null: true, - description: 'Name of the analyzer.' - - field :label, GraphQL::STRING_TYPE, null: true, - description: 'Analyzer label used in the config UI.' - - field :enabled, GraphQL::BOOLEAN_TYPE, null: true, - description: 'Indicates whether an analyzer is enabled.' - - field :description, GraphQL::STRING_TYPE, null: true, - description: 'Analyzer description that is displayed on the form.' - end - end - end -end diff --git a/app/graphql/types/ci_configuration/sast/entity_type.rb b/app/graphql/types/ci_configuration/sast/entity_type.rb deleted file mode 100644 index b61b582ad20..00000000000 --- a/app/graphql/types/ci_configuration/sast/entity_type.rb +++ /dev/null @@ -1,34 +0,0 @@ -# frozen_string_literal: true - -module Types - module CiConfiguration - module Sast - # rubocop: disable Graphql/AuthorizeTypes - class EntityType < BaseObject - graphql_name 'SastCiConfigurationEntity' - description 'Represents an entity in SAST CI configuration' - - field :field, GraphQL::STRING_TYPE, null: true, - description: 'CI keyword of entity.' - - field :label, GraphQL::STRING_TYPE, null: true, - description: 'Label for entity used in the form.' - - field :type, GraphQL::STRING_TYPE, null: true, - description: 'Type of the field value.' - - field :options, ::Types::CiConfiguration::Sast::OptionsEntityType.connection_type, null: true, - description: 'Different possible values of the field.' - - field :default_value, GraphQL::STRING_TYPE, null: true, - description: 'Default value that is used if value is empty.' - - field :description, GraphQL::STRING_TYPE, null: true, - description: 'Entity description that is displayed on the form.' - - field :value, GraphQL::STRING_TYPE, null: true, - description: 'Current value of the entity.' - end - end - end -end diff --git a/app/graphql/types/ci_configuration/sast/options_entity_type.rb b/app/graphql/types/ci_configuration/sast/options_entity_type.rb deleted file mode 100644 index 86d104a7fda..00000000000 --- a/app/graphql/types/ci_configuration/sast/options_entity_type.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -module Types - module CiConfiguration - module Sast - # rubocop: disable Graphql/AuthorizeTypes - class OptionsEntityType < BaseObject - graphql_name 'SastCiConfigurationOptionsEntity' - description 'Represents an entity for options in SAST CI configuration' - - field :label, GraphQL::STRING_TYPE, null: true, - description: 'Label of option entity.' - - field :value, GraphQL::STRING_TYPE, null: true, - description: 'Value of option entity.' - end - end - end -end diff --git a/app/graphql/types/ci_configuration/sast/type.rb b/app/graphql/types/ci_configuration/sast/type.rb deleted file mode 100644 index 35d11584ac7..00000000000 --- a/app/graphql/types/ci_configuration/sast/type.rb +++ /dev/null @@ -1,22 +0,0 @@ -# frozen_string_literal: true - -module Types - module CiConfiguration - module Sast - # rubocop: disable Graphql/AuthorizeTypes - class Type < BaseObject - graphql_name 'SastCiConfiguration' - description 'Represents a CI configuration of SAST' - - field :global, ::Types::CiConfiguration::Sast::EntityType.connection_type, null: true, - description: 'List of global entities related to SAST configuration.' - - field :pipeline, ::Types::CiConfiguration::Sast::EntityType.connection_type, null: true, - description: 'List of pipeline entities related to SAST configuration.' - - field :analyzers, ::Types::CiConfiguration::Sast::AnalyzersEntityType.connection_type, null: true, - description: 'List of analyzers entities attached to SAST configuration.' - end - end - end -end diff --git a/app/graphql/types/commit_type.rb b/app/graphql/types/commit_type.rb index be5165da545..dd4b4c3b114 100644 --- a/app/graphql/types/commit_type.rb +++ b/app/graphql/types/commit_type.rb @@ -17,12 +17,15 @@ module Types markdown_field :title_html, null: true field :description, type: GraphQL::STRING_TYPE, null: true, description: 'Description of the commit message' + markdown_field :description_html, null: true field :message, type: GraphQL::STRING_TYPE, null: true, description: 'Raw commit message' field :authored_date, type: Types::TimeType, null: true, description: 'Timestamp of when the commit was authored' field :web_url, type: GraphQL::STRING_TYPE, null: false, description: 'Web URL of the commit' + field :web_path, type: GraphQL::STRING_TYPE, null: false, + description: 'Web path of the commit' field :signature_html, type: GraphQL::STRING_TYPE, null: true, calls_gitaly: true, description: 'Rendered HTML of the commit signature' field :author_name, type: GraphQL::STRING_TYPE, null: true, diff --git a/app/graphql/types/countable_connection_type.rb b/app/graphql/types/countable_connection_type.rb new file mode 100644 index 00000000000..2538366b786 --- /dev/null +++ b/app/graphql/types/countable_connection_type.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +module Types + # rubocop: disable Graphql/AuthorizeTypes + class CountableConnectionType < GraphQL::Types::Relay::BaseConnection + field :count, Integer, null: false, + description: 'Total count of collection' + + def count + # rubocop: disable CodeReuse/ActiveRecord + relation = object.items + + # sometimes relation is an Array + relation = relation.reorder(nil) if relation.respond_to?(:reorder) + # rubocop: enable CodeReuse/ActiveRecord + + if relation.try(:group_values)&.present? + relation.size.keys.size + else + relation.size + end + end + end +end diff --git a/app/graphql/types/environment_type.rb b/app/graphql/types/environment_type.rb index 34a90006d03..239b26f9c38 100644 --- a/app/graphql/types/environment_type.rb +++ b/app/graphql/types/environment_type.rb @@ -19,5 +19,10 @@ module Types field :metrics_dashboard, Types::Metrics::DashboardType, null: true, description: 'Metrics dashboard schema for the environment', resolver: Resolvers::Metrics::DashboardResolver + + field :latest_opened_most_severe_alert, + Types::AlertManagement::AlertType, + null: true, + description: 'The most severe open alert for the environment. If multiple alerts have equal severity, the most recent is returned.' end end diff --git a/app/graphql/types/group_type.rb b/app/graphql/types/group_type.rb index fd7d9a9ba3d..cc8cd7c01f9 100644 --- a/app/graphql/types/group_type.rb +++ b/app/graphql/types/group_type.rb @@ -47,11 +47,11 @@ module Types Types::IssueType.connection_type, null: true, description: 'Issues of the group', - resolver: Resolvers::IssuesResolver + resolver: Resolvers::GroupIssuesResolver field :milestones, Types::MilestoneType.connection_type, null: true, - description: 'Find milestones', - resolver: Resolvers::MilestoneResolver + description: 'Milestones of the group', + resolver: Resolvers::GroupMilestonesResolver field :boards, Types::BoardType.connection_type, diff --git a/app/graphql/types/issuable_state_enum.rb b/app/graphql/types/issuable_state_enum.rb index f2f6d6c6cab..543b7f8e5b2 100644 --- a/app/graphql/types/issuable_state_enum.rb +++ b/app/graphql/types/issuable_state_enum.rb @@ -8,5 +8,6 @@ module Types value 'opened' value 'closed' value 'locked' + value 'all' end end diff --git a/app/graphql/types/issue_connection_type.rb b/app/graphql/types/issue_connection_type.rb deleted file mode 100644 index beed392f01a..00000000000 --- a/app/graphql/types/issue_connection_type.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -module Types - # rubocop: disable Graphql/AuthorizeTypes - class IssueConnectionType < GraphQL::Types::Relay::BaseConnection - field :count, Integer, null: false, - description: 'Total count of collection' - - def count - object.items.size - end - end -end diff --git a/app/graphql/types/issue_status_counts_type.rb b/app/graphql/types/issue_status_counts_type.rb new file mode 100644 index 00000000000..f2b1ba8e655 --- /dev/null +++ b/app/graphql/types/issue_status_counts_type.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +module Types + class IssueStatusCountsType < BaseObject + graphql_name 'IssueStatusCountsType' + description "Represents total number of issues for the represented statuses." + + authorize :read_issue + + def self.available_issue_states + @available_issue_states ||= Issue.available_states.keys.push('all') + end + + ::Gitlab::IssuablesCountForState::STATES.each do |state| + next unless available_issue_states.include?(state.downcase) + + field state, + GraphQL::INT_TYPE, + null: true, + description: "Number of issues with status #{state.upcase} for the project" + end + end +end diff --git a/app/graphql/types/issue_type.rb b/app/graphql/types/issue_type.rb index 9baa0018999..0a73ce95424 100644 --- a/app/graphql/types/issue_type.rb +++ b/app/graphql/types/issue_type.rb @@ -4,7 +4,7 @@ module Types class IssueType < BaseObject graphql_name 'Issue' - connection_type_class(Types::IssueConnectionType) + connection_type_class(Types::CountableConnectionType) implements(Types::Notes::NoteableType) @@ -97,6 +97,10 @@ module Types field :design_collection, Types::DesignManagement::DesignCollectionType, null: true, description: 'Collection of design images associated with this issue' + + field :type, Types::IssueTypeEnum, null: true, + method: :issue_type, + description: 'Type of the issue' end end diff --git a/app/graphql/types/issue_type_enum.rb b/app/graphql/types/issue_type_enum.rb new file mode 100644 index 00000000000..7dc45f78c99 --- /dev/null +++ b/app/graphql/types/issue_type_enum.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +module Types + class IssueTypeEnum < BaseEnum + graphql_name 'IssueType' + description 'Issue type' + + ::Issue.issue_types.keys.each do |issue_type| + value issue_type.upcase, value: issue_type, description: "#{issue_type.titleize} issue type" + end + end +end diff --git a/app/graphql/types/merge_request_type.rb b/app/graphql/types/merge_request_type.rb index c194b467363..01b02b7976f 100644 --- a/app/graphql/types/merge_request_type.rb +++ b/app/graphql/types/merge_request_type.rb @@ -4,6 +4,8 @@ module Types class MergeRequestType < BaseObject graphql_name 'MergeRequest' + connection_type_class(Types::CountableConnectionType) + implements(Types::Notes::NoteableType) authorize :read_merge_request @@ -141,6 +143,8 @@ module Types end field :task_completion_status, Types::TaskCompletionStatus, null: false, description: Types::TaskCompletionStatus.description + field :commit_count, GraphQL::INT_TYPE, null: true, + description: 'Number of commits in the merge request' def diff_stats(path: nil) stats = Array.wrap(object.diff_stats&.to_a) @@ -160,5 +164,14 @@ module Types hash.merge!(additions: status.additions, deletions: status.deletions, file_count: 1) { |_, x, y| x + y } end end + + def commit_count + object&.metrics&.commits_count + end + + def approvers + object.approver_users + end end end +Types::MergeRequestType.prepend_if_ee('::EE::Types::MergeRequestType') diff --git a/app/graphql/types/mutation_type.rb b/app/graphql/types/mutation_type.rb index 49d51b626b2..e143d14676e 100644 --- a/app/graphql/types/mutation_type.rb +++ b/app/graphql/types/mutation_type.rb @@ -14,12 +14,17 @@ module Types mount_mutation Mutations::AwardEmojis::Add mount_mutation Mutations::AwardEmojis::Remove mount_mutation Mutations::AwardEmojis::Toggle + mount_mutation Mutations::Boards::Issues::IssueMoveList + mount_mutation Mutations::Boards::Lists::Create + mount_mutation Mutations::Boards::Lists::Update mount_mutation Mutations::Branches::Create, calls_gitaly: true mount_mutation Mutations::Commits::Create, calls_gitaly: true mount_mutation Mutations::Discussions::ToggleResolve + mount_mutation Mutations::Issues::SetAssignees mount_mutation Mutations::Issues::SetConfidential mount_mutation Mutations::Issues::SetLocked mount_mutation Mutations::Issues::SetDueDate + mount_mutation Mutations::Issues::SetSubscription mount_mutation Mutations::Issues::Update mount_mutation Mutations::MergeRequests::Create mount_mutation Mutations::MergeRequests::Update @@ -55,6 +60,7 @@ module Types mount_mutation Mutations::JiraImport::ImportUsers mount_mutation Mutations::DesignManagement::Upload, calls_gitaly: true mount_mutation Mutations::DesignManagement::Delete, calls_gitaly: true + mount_mutation Mutations::DesignManagement::Move mount_mutation Mutations::ContainerExpirationPolicies::Update end end diff --git a/app/graphql/types/project_type.rb b/app/graphql/types/project_type.rb index 2251a0f4e0c..5562db69de6 100644 --- a/app/graphql/types/project_type.rb +++ b/app/graphql/types/project_type.rb @@ -148,6 +148,16 @@ module Types description: 'Issues of the project', resolver: Resolvers::IssuesResolver + field :issue_status_counts, + Types::IssueStatusCountsType, + null: true, + description: 'Counts of issues by status for the project', + resolver: Resolvers::IssueStatusCountsResolver + + field :milestones, Types::MilestoneType.connection_type, null: true, + description: 'Milestones of the project', + resolver: Resolvers::ProjectMilestonesResolver + field :project_members, Types::ProjectMemberType.connection_type, description: 'Members of the project', @@ -159,9 +169,11 @@ module Types description: 'Environments of the project', resolver: Resolvers::EnvironmentsResolver - field :sast_ci_configuration, ::Types::CiConfiguration::Sast::Type, null: true, - description: 'SAST CI configuration for the project', - resolver: ::Resolvers::CiConfiguration::SastResolver + field :environment, + Types::EnvironmentType, + null: true, + description: 'A single environment of the project', + resolver: Resolvers::EnvironmentsResolver.single field :issue, Types::IssueType, diff --git a/app/graphql/types/projects/services/jira_service_type.rb b/app/graphql/types/projects/services/jira_service_type.rb index 8bf85a14cbf..cb0712249e3 100644 --- a/app/graphql/types/projects/services/jira_service_type.rb +++ b/app/graphql/types/projects/services/jira_service_type.rb @@ -13,8 +13,6 @@ module Types field :projects, Types::Projects::Services::JiraProjectType.connection_type, null: true, - connection: false, - extensions: [Gitlab::Graphql::Extensions::ExternallyPaginatedArrayExtension], description: 'List of all Jira projects fetched through Jira REST API', resolver: Resolvers::Projects::JiraProjectsResolver end diff --git a/app/graphql/types/prometheus_alert_type.rb b/app/graphql/types/prometheus_alert_type.rb new file mode 100644 index 00000000000..1d09a8dbeb7 --- /dev/null +++ b/app/graphql/types/prometheus_alert_type.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +module Types + class PrometheusAlertType < BaseObject + graphql_name 'PrometheusAlert' + description 'The alert condition for Prometheus' + + authorize :read_prometheus_alerts + + present_using PrometheusAlertPresenter + + field :id, GraphQL::ID_TYPE, null: false, + description: 'ID of the alert condition' + + field :humanized_text, + GraphQL::STRING_TYPE, + null: false, + description: 'The human-readable text of the alert condition' + end +end diff --git a/app/graphql/types/query_type.rb b/app/graphql/types/query_type.rb index b4cbd96bfdb..c04f4da70cf 100644 --- a/app/graphql/types/query_type.rb +++ b/app/graphql/types/query_type.rb @@ -47,6 +47,15 @@ module Types null: false, description: 'Fields related to design management' + field :milestone, ::Types::MilestoneType, + null: true, + description: 'Find a milestone', + resolve: -> (_obj, args, _ctx) { GitlabSchema.find_by_gid(args[:id]) } do + argument :id, ::Types::GlobalIDType[Milestone], + required: true, + description: 'Find a milestone by its ID' + end + field :user, Types::UserType, null: true, description: 'Find a user', diff --git a/app/graphql/types/snippet_type.rb b/app/graphql/types/snippet_type.rb index 73ca3425ded..db98e62c10a 100644 --- a/app/graphql/types/snippet_type.rb +++ b/app/graphql/types/snippet_type.rb @@ -66,7 +66,8 @@ module Types field :blob, type: Types::Snippets::BlobType, description: 'Snippet blob', calls_gitaly: true, - null: false + null: false, + deprecated: { reason: 'Use `blobs`', milestone: '13.3' } field :blobs, type: [Types::Snippets::BlobType], description: 'Snippet blobs', diff --git a/app/graphql/types/snippets/file_input_action_enum.rb b/app/graphql/types/snippets/blob_action_enum.rb index 7785853f3a8..e3f89920f16 100644 --- a/app/graphql/types/snippets/file_input_action_enum.rb +++ b/app/graphql/types/snippets/blob_action_enum.rb @@ -2,9 +2,9 @@ module Types module Snippets - class FileInputActionEnum < BaseEnum - graphql_name 'SnippetFileInputActionEnum' - description 'Type of a snippet file input action' + class BlobActionEnum < BaseEnum + graphql_name 'SnippetBlobActionEnum' + description 'Type of a snippet blob input action' value 'create', value: :create value 'update', value: :update diff --git a/app/graphql/types/snippets/file_input_type.rb b/app/graphql/types/snippets/blob_action_input_type.rb index 85a02c8f493..ccb6ae3f2c1 100644 --- a/app/graphql/types/snippets/file_input_type.rb +++ b/app/graphql/types/snippets/blob_action_input_type.rb @@ -2,11 +2,11 @@ module Types module Snippets - class FileInputType < BaseInputObject # rubocop:disable Graphql/AuthorizeTypes - graphql_name 'SnippetFileInputType' + class BlobActionInputType < BaseInputObject # rubocop:disable Graphql/AuthorizeTypes + graphql_name 'SnippetBlobActionInputType' description 'Represents an action to perform over a snippet file' - argument :action, Types::Snippets::FileInputActionEnum, + argument :action, Types::Snippets::BlobActionEnum, description: 'Type of input action', required: true diff --git a/app/graphql/types/time_type.rb b/app/graphql/types/time_type.rb index f045a50e672..c31e4873df0 100644 --- a/app/graphql/types/time_type.rb +++ b/app/graphql/types/time_type.rb @@ -7,6 +7,8 @@ module Types def self.coerce_input(value, ctx) Time.parse(value) + rescue ArgumentError, TypeError => e + raise GraphQL::CoercionError, e.message end def self.coerce_result(value, ctx) diff --git a/app/graphql/types/tree/blob_type.rb b/app/graphql/types/tree/blob_type.rb index 36cae756a0d..cc6bf7b4f00 100644 --- a/app/graphql/types/tree/blob_type.rb +++ b/app/graphql/types/tree/blob_type.rb @@ -12,6 +12,8 @@ module Types field :web_url, GraphQL::STRING_TYPE, null: true, description: 'Web URL of the blob' + field :web_path, GraphQL::STRING_TYPE, null: true, + description: 'Web path of the blob' field :lfs_oid, GraphQL::STRING_TYPE, null: true, description: 'LFS ID of the blob', resolve: -> (blob, args, ctx) do diff --git a/app/graphql/types/tree/tree_entry_type.rb b/app/graphql/types/tree/tree_entry_type.rb index 81a7a7e66ae..aff2e025761 100644 --- a/app/graphql/types/tree/tree_entry_type.rb +++ b/app/graphql/types/tree/tree_entry_type.rb @@ -13,6 +13,8 @@ module Types field :web_url, GraphQL::STRING_TYPE, null: true, description: 'Web URL for the tree entry (directory)' + field :web_path, GraphQL::STRING_TYPE, null: true, + description: 'Web path for the tree entry (directory)' end # rubocop: enable Graphql/AuthorizeTypes end diff --git a/app/graphql/types/user_status_type.rb b/app/graphql/types/user_status_type.rb new file mode 100644 index 00000000000..ff277c1f8e8 --- /dev/null +++ b/app/graphql/types/user_status_type.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +module Types + # rubocop: disable Graphql/AuthorizeTypes + class UserStatusType < BaseObject + graphql_name 'UserStatus' + + markdown_field :message_html, null: true, + description: 'HTML of the user status message' + field :message, GraphQL::STRING_TYPE, null: true, + description: 'User status message' + field :emoji, GraphQL::STRING_TYPE, null: true, + description: 'String representation of emoji' + end +end diff --git a/app/graphql/types/user_type.rb b/app/graphql/types/user_type.rb index ab3c84ea539..cb3575b41d1 100644 --- a/app/graphql/types/user_type.rb +++ b/app/graphql/types/user_type.rb @@ -18,16 +18,22 @@ module Types description: 'Human-readable name of the user' field :state, Types::UserStateEnum, null: false, description: 'State of the user' + field :email, GraphQL::STRING_TYPE, null: true, + description: 'User email' field :avatar_url, GraphQL::STRING_TYPE, null: true, description: "URL of the user's avatar" field :web_url, GraphQL::STRING_TYPE, null: false, description: 'Web URL of the user' + field :web_path, GraphQL::STRING_TYPE, null: false, + description: 'Web path of the user' 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 :status, Types::UserStatusType, null: true, + description: 'User status' field :project_memberships, Types::ProjectMemberType.connection_type, null: true, description: 'Project memberships of the user', method: :project_members |