summaryrefslogtreecommitdiff
path: root/app/graphql/types/commit_type.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/graphql/types/commit_type.rb')
-rw-r--r--app/graphql/types/commit_type.rb30
1 files changed, 30 insertions, 0 deletions
diff --git a/app/graphql/types/commit_type.rb b/app/graphql/types/commit_type.rb
new file mode 100644
index 00000000000..d73dd73affd
--- /dev/null
+++ b/app/graphql/types/commit_type.rb
@@ -0,0 +1,30 @@
+# frozen_string_literal: true
+
+module Types
+ class CommitType < BaseObject
+ graphql_name 'Commit'
+
+ authorize :download_code
+
+ present_using CommitPresenter
+
+ field :id, type: GraphQL::ID_TYPE, null: false
+ field :sha, type: GraphQL::STRING_TYPE, null: false
+ field :title, type: GraphQL::STRING_TYPE, null: true
+ field :description, type: GraphQL::STRING_TYPE, null: true
+ field :message, type: GraphQL::STRING_TYPE, null: true
+ field :authored_date, type: Types::TimeType, null: true
+ field :web_url, type: GraphQL::STRING_TYPE, null: false
+
+ # models/commit lazy loads the author by email
+ field :author, type: Types::UserType, null: true
+
+ field :latest_pipeline,
+ type: Types::Ci::PipelineType,
+ null: true,
+ description: "Latest pipeline for this commit",
+ resolve: -> (obj, ctx, args) do
+ Gitlab::Graphql::Loaders::PipelineForShaLoader.new(obj.project, obj.sha).find_last
+ end
+ end
+end