diff options
author | Phil Hughes <me@iamphill.com> | 2019-05-22 14:43:35 +0300 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2019-05-22 14:43:35 +0300 |
commit | 67a50861953be9347e267795a9ce736dfea5316b (patch) | |
tree | b9546274a629204b8c2ae9a60c5da70ae3a06ba7 /app/graphql/resolvers/tree_resolver.rb | |
parent | c841c8771b8d69034c1ceb6e452746d193865cb0 (diff) |
Added repository files to GraphQL API
Diffstat (limited to 'app/graphql/resolvers/tree_resolver.rb')
-rw-r--r-- | app/graphql/resolvers/tree_resolver.rb | 26 |
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 |