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/types/tree | |
parent | c841c8771b8d69034c1ceb6e452746d193865cb0 (diff) |
Added repository files to GraphQL API
Diffstat (limited to 'app/graphql/types/tree')
-rw-r--r-- | app/graphql/types/tree/blob_type.rb | 10 | ||||
-rw-r--r-- | app/graphql/types/tree/entry_type.rb | 14 | ||||
-rw-r--r-- | app/graphql/types/tree/submodule_type.rb | 10 | ||||
-rw-r--r-- | app/graphql/types/tree/tree_entry_type.rb | 11 | ||||
-rw-r--r-- | app/graphql/types/tree/tree_type.rb | 12 | ||||
-rw-r--r-- | app/graphql/types/tree/type_enum.rb | 14 |
6 files changed, 71 insertions, 0 deletions
diff --git a/app/graphql/types/tree/blob_type.rb b/app/graphql/types/tree/blob_type.rb new file mode 100644 index 00000000000..230624201b0 --- /dev/null +++ b/app/graphql/types/tree/blob_type.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true +module Types + module Tree + class BlobType < BaseObject + implements Types::Tree::EntryType + + graphql_name 'Blob' + end + end +end diff --git a/app/graphql/types/tree/entry_type.rb b/app/graphql/types/tree/entry_type.rb new file mode 100644 index 00000000000..d8e8642ddb8 --- /dev/null +++ b/app/graphql/types/tree/entry_type.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true +module Types + module Tree + module EntryType + include Types::BaseInterface + + field :id, GraphQL::ID_TYPE, null: false + field :name, GraphQL::STRING_TYPE, null: false + field :type, Tree::TypeEnum, null: false + field :path, GraphQL::STRING_TYPE, null: false + field :flat_path, GraphQL::STRING_TYPE, null: false + end + end +end diff --git a/app/graphql/types/tree/submodule_type.rb b/app/graphql/types/tree/submodule_type.rb new file mode 100644 index 00000000000..cea76dbfd2a --- /dev/null +++ b/app/graphql/types/tree/submodule_type.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true +module Types + module Tree + class SubmoduleType < BaseObject + implements Types::Tree::EntryType + + graphql_name 'Submodule' + end + end +end diff --git a/app/graphql/types/tree/tree_entry_type.rb b/app/graphql/types/tree/tree_entry_type.rb new file mode 100644 index 00000000000..d5cfb898aea --- /dev/null +++ b/app/graphql/types/tree/tree_entry_type.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true +module Types + module Tree + class TreeEntryType < BaseObject + implements Types::Tree::EntryType + + graphql_name 'TreeEntry' + description 'Represents a directory' + end + end +end diff --git a/app/graphql/types/tree/tree_type.rb b/app/graphql/types/tree/tree_type.rb new file mode 100644 index 00000000000..1eb6c43972e --- /dev/null +++ b/app/graphql/types/tree/tree_type.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true +module Types + module Tree + class TreeType < BaseObject + graphql_name 'Tree' + + field :trees, Types::Tree::TreeEntryType.connection_type, null: false + field :submodules, Types::Tree::SubmoduleType.connection_type, null: false + field :blobs, Types::Tree::BlobType.connection_type, null: false + end + end +end diff --git a/app/graphql/types/tree/type_enum.rb b/app/graphql/types/tree/type_enum.rb new file mode 100644 index 00000000000..6560d91e9e5 --- /dev/null +++ b/app/graphql/types/tree/type_enum.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +module Types + module Tree + class TypeEnum < BaseEnum + graphql_name 'EntryType' + description 'Type of a tree entry' + + value 'tree', value: :tree + value 'blob', value: :blob + value 'commit', value: :commit + end + end +end |