summaryrefslogtreecommitdiff
path: root/app/graphql/types/snippets/blob_type.rb
blob: bb4a0a64de84f5577a277e15aa1b80deaf5b3cfc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# frozen_string_literal: true

module Types
  module Snippets
    # rubocop: disable Graphql/AuthorizeTypes
    class BlobType < BaseObject
      graphql_name 'SnippetBlob'
      description 'Represents the snippet blob'
      present_using SnippetBlobPresenter

      connection_type_class(Types::Snippets::BlobConnectionType)

      field :rich_data, GraphQL::Types::String,
            description: 'Blob highlighted data.',
            null: true

      field :plain_data, GraphQL::Types::String,
            description: 'Blob plain highlighted data.',
            null: true

      field :raw_plain_data, GraphQL::Types::String,
            description: 'Raw content of the blob, if the blob is text data.',
            null: true

      field :raw_path, GraphQL::Types::String,
            description: 'Blob raw content endpoint path.',
            null: false

      field :size, GraphQL::Types::Int,
            description: 'Blob size.',
            null: false

      field :binary, GraphQL::Types::Boolean,
            description: 'Shows whether the blob is binary.',
            method: :binary?,
            null: false

      field :name, GraphQL::Types::String,
            description: 'Blob name.',
            null: true

      field :path, GraphQL::Types::String,
            description: 'Blob path.',
            null: true

      field :simple_viewer, type: Types::Snippets::BlobViewerType,
                            description: 'Blob content simple viewer.',
                            null: false

      field :rich_viewer, type: Types::Snippets::BlobViewerType,
                          description: 'Blob content rich viewer.',
                          null: true

      field :mode, type: GraphQL::Types::String,
                   description: 'Blob mode.',
                   null: true

      field :external_storage, type: GraphQL::Types::String,
                               description: 'Blob external storage.',
                               null: true

      field :rendered_as_text, type: GraphQL::Types::Boolean,
                               description: 'Shows whether the blob is rendered as text.',
                               method: :rendered_as_text?,
                               null: false
    end
    # rubocop: enable Graphql/AuthorizeTypes
  end
end