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:
authorPhil Hughes <me@iamphill.com>2019-05-22 14:43:35 +0300
committerPhil Hughes <me@iamphill.com>2019-05-22 14:43:35 +0300
commit67a50861953be9347e267795a9ce736dfea5316b (patch)
treeb9546274a629204b8c2ae9a60c5da70ae3a06ba7 /app/graphql/resolvers/tree_resolver.rb
parentc841c8771b8d69034c1ceb6e452746d193865cb0 (diff)
Added repository files to GraphQL API
Diffstat (limited to 'app/graphql/resolvers/tree_resolver.rb')
-rw-r--r--app/graphql/resolvers/tree_resolver.rb26
1 files changed, 26 insertions, 0 deletions
diff --git a/app/graphql/resolvers/tree_resolver.rb b/app/graphql/resolvers/tree_resolver.rb
new file mode 100644
index 00000000000..5aad1c71b40
--- /dev/null
+++ b/app/graphql/resolvers/tree_resolver.rb
@@ -0,0 +1,26 @@
+# frozen_string_literal: true
+
+module Resolvers
+ class TreeResolver < BaseResolver
+ argument :path, GraphQL::STRING_TYPE,
+ required: false,
+ default_value: '',
+ description: 'The path to get the tree for. Default value is the root of the repository'
+ argument :ref, GraphQL::STRING_TYPE,
+ required: false,
+ default_value: :head,
+ description: 'The commit ref to get the tree for. Default value is HEAD'
+ argument :recursive, GraphQL::BOOLEAN_TYPE,
+ required: false,
+ default_value: false,
+ description: 'Used to get a recursive tree. Default is false'
+
+ alias_method :repository, :object
+
+ def resolve(**args)
+ return unless repository.exists?
+
+ repository.tree(args[:ref], args[:path], recursive: args[:recursive])
+ end
+ end
+end