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>2019-10-17 18:06:17 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2019-10-17 18:06:17 +0300
commit238d22c07218adf2b8f3db630ee8b74ca6f29df5 (patch)
tree23fd5f85efef0fb95eb73bf6395d5b7e8c0f1b9f /app/graphql/types
parent6b75320f525f841454f1ab162d141d3610f2e77b (diff)
Add latest changes from gitlab-org/gitlab@masterlist
Diffstat (limited to 'app/graphql/types')
-rw-r--r--app/graphql/types/query_type.rb5
-rw-r--r--app/graphql/types/todo_action_enum.rb13
-rw-r--r--app/graphql/types/todo_state_enum.rb8
-rw-r--r--app/graphql/types/todo_target_enum.rb9
-rw-r--r--app/graphql/types/todo_type.rb53
-rw-r--r--app/graphql/types/user_type.rb3
6 files changed, 91 insertions, 0 deletions
diff --git a/app/graphql/types/query_type.rb b/app/graphql/types/query_type.rb
index bbf94fb92df..996bf225976 100644
--- a/app/graphql/types/query_type.rb
+++ b/app/graphql/types/query_type.rb
@@ -14,6 +14,11 @@ module Types
resolver: Resolvers::GroupResolver,
description: "Find a group"
+ field :current_user, Types::UserType,
+ null: true,
+ resolve: -> (_obj, _args, context) { context[:current_user] },
+ description: "Get information about current user"
+
field :namespace, Types::NamespaceType,
null: true,
resolver: Resolvers::NamespaceResolver,
diff --git a/app/graphql/types/todo_action_enum.rb b/app/graphql/types/todo_action_enum.rb
new file mode 100644
index 00000000000..0e538838474
--- /dev/null
+++ b/app/graphql/types/todo_action_enum.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+module Types
+ class TodoActionEnum < BaseEnum
+ value 'assigned', value: 1
+ value 'mentioned', value: 2
+ value 'build_failed', value: 3
+ value 'marked', value: 4
+ value 'approval_required', value: 5
+ value 'unmergeable', value: 6
+ value 'directly_addressed', value: 7
+ end
+end
diff --git a/app/graphql/types/todo_state_enum.rb b/app/graphql/types/todo_state_enum.rb
new file mode 100644
index 00000000000..29a28b5208d
--- /dev/null
+++ b/app/graphql/types/todo_state_enum.rb
@@ -0,0 +1,8 @@
+# frozen_string_literal: true
+
+module Types
+ class TodoStateEnum < BaseEnum
+ value 'pending'
+ value 'done'
+ end
+end
diff --git a/app/graphql/types/todo_target_enum.rb b/app/graphql/types/todo_target_enum.rb
new file mode 100644
index 00000000000..9a7391dcd99
--- /dev/null
+++ b/app/graphql/types/todo_target_enum.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+module Types
+ class TodoTargetEnum < BaseEnum
+ value 'Issue'
+ value 'MergeRequest'
+ value 'Epic'
+ end
+end
diff --git a/app/graphql/types/todo_type.rb b/app/graphql/types/todo_type.rb
new file mode 100644
index 00000000000..d36daaf7dec
--- /dev/null
+++ b/app/graphql/types/todo_type.rb
@@ -0,0 +1,53 @@
+# frozen_string_literal: true
+
+module Types
+ class TodoType < BaseObject
+ graphql_name 'Todo'
+ description 'Representing a todo entry'
+
+ present_using TodoPresenter
+
+ authorize :read_todo
+
+ field :id, GraphQL::ID_TYPE,
+ description: 'Id of the todo',
+ null: false
+
+ field :project, Types::ProjectType,
+ description: 'The project this todo is associated with',
+ null: true,
+ authorize: :read_project,
+ resolve: -> (todo, args, context) { Gitlab::Graphql::Loaders::BatchModelLoader.new(Project, todo.project_id).find }
+
+ field :group, Types::GroupType,
+ description: 'Group this todo is associated with',
+ null: true,
+ authorize: :read_group,
+ resolve: -> (todo, args, context) { Gitlab::Graphql::Loaders::BatchModelLoader.new(Group, todo.group_id).find }
+
+ field :author, Types::UserType,
+ description: 'The owner of this todo',
+ null: false,
+ resolve: -> (todo, args, context) { Gitlab::Graphql::Loaders::BatchModelLoader.new(User, todo.author_id).find }
+
+ field :action, Types::TodoActionEnum,
+ description: 'Action of the todo',
+ null: false
+
+ field :target_type, Types::TodoTargetEnum,
+ description: 'Target type of the todo',
+ null: false
+
+ field :body, GraphQL::STRING_TYPE,
+ description: 'Body of the todo',
+ null: false
+
+ field :state, Types::TodoStateEnum,
+ description: 'State of the todo',
+ null: false
+
+ field :created_at, Types::TimeType,
+ description: 'Timestamp this todo was created',
+ null: false
+ end
+end
diff --git a/app/graphql/types/user_type.rb b/app/graphql/types/user_type.rb
index 9f7d2a171d6..1ba37927b40 100644
--- a/app/graphql/types/user_type.rb
+++ b/app/graphql/types/user_type.rb
@@ -12,5 +12,8 @@ module Types
field :username, GraphQL::STRING_TYPE, null: false # rubocop:disable Graphql/Descriptions
field :avatar_url, GraphQL::STRING_TYPE, null: false # rubocop:disable Graphql/Descriptions
field :web_url, GraphQL::STRING_TYPE, null: false # rubocop:disable Graphql/Descriptions
+ field :todos, Types::TodoType.connection_type, null: false,
+ resolver: Resolvers::TodoResolver,
+ description: 'Todos of this user'
end
end